From 06cf55aa7343985b413efd913017266cb4e4885d Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 12 Jul 2025 21:45:51 +0100 Subject: [PATCH] Hlint pass --- src/Dodge/Data/ComposedItem.hs | 2 -- src/Dodge/Item/Draw/SPic.hs | 4 ++-- src/Dodge/Item/Grammar.hs | 27 +++++++++++---------------- src/Dodge/Item/HeldOffset.hs | 2 +- src/Dodge/Item/Orientation.hs | 7 ------- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/Dodge/Data/ComposedItem.hs b/src/Dodge/Data/ComposedItem.hs index f45db98fa..fba297882 100644 --- a/src/Dodge/Data/ComposedItem.hs +++ b/src/Dodge/Data/ComposedItem.hs @@ -1,7 +1,5 @@ -{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE StrictData #-} -{-# LANGUAGE TemplateHaskell #-} module Dodge.Data.ComposedItem where diff --git a/src/Dodge/Item/Draw/SPic.hs b/src/Dodge/Item/Draw/SPic.hs index 2d6f01e1a..b30f25e69 100644 --- a/src/Dodge/Item/Draw/SPic.hs +++ b/src/Dodge/Item/Draw/SPic.hs @@ -24,8 +24,8 @@ import ShapePicture itemTreeSPic :: DTree CItem -> SPic itemTreeSPic (DT (itm,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (l <> r) -itemRotTreeSPic :: Item -> (DTree CItem) -> SPic -itemRotTreeSPic par ( t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t +itemRotTreeSPic :: Item -> DTree CItem -> SPic +itemRotTreeSPic par t = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t where (p, q) = orientAttachment par itm itm = t ^. dtValue diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index 20fe39e83..13d4b4ae7 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -52,10 +52,10 @@ tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine itemToBreakLists :: Item -> ItemStructuralFunction -> - ([(ItemStructuralFunction)], [(ItemStructuralFunction)]) + ([ItemStructuralFunction], [ItemStructuralFunction]) itemToBreakLists itm itmf = case (itm ^. itType, itmf) of (HELD TORCH, _) -> (getAmmoLinks itm, []) - (ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF)], []) + (ATTACH UNDERBARRELSLOT, _) -> ([UnderBarrelPlatformSF], []) (_, HeldPlatformSF) -> ( getAmmoLinks itm <> extraWeaponLinksBelow itm @@ -181,41 +181,36 @@ type DTComb a = DTree a -> DTree a -> Maybe (DTree a) leftIsParentCombine :: DTComb CItem leftIsParentCombine ltree rtree = do let l = rightChildList ltree - xs = dropWhile ((\s -> not $ S.member s (treeToPotentialFunction rtree))) l - (sf) <- safeHead xs + xs = dropWhile (\s -> not $ S.member s (treeToPotentialFunction rtree)) l + sf <- safeHead xs return $ ltree & dtRight .:~ ( rtree & dtValue . _2 .~ sf) rightIsParentCombine :: DTComb CItem rightIsParentCombine ltree rtree = do let l = leftChildList rtree - xs = dropWhile ((\s -> not $ S.member s (treeToPotentialFunction ltree))) l - (sf) <- safeHead xs + xs = dropWhile (\s -> not $ S.member s (treeToPotentialFunction ltree)) l + sf <- safeHead xs return $ rtree & dtLeft .:~ ( ltree & dtValue . _2 .~ sf) leftChildList :: DTree CItem -> [ItemStructuralFunction] leftChildList t = foldl' f l (reverse $ t ^.. dtLeft . each . dtValue . _2) where l = fst $ itemToBreakLists (t ^. dtValue . _1) (t ^. dtValue . _2) - f x y = tail $ dropWhile ((/=y) ) x + f x y = tail $ dropWhile (/=y) x rightChildList :: DTree CItem -> [ItemStructuralFunction] rightChildList t = foldl' f l (reverse $ t ^.. dtRight . each . dtValue . _2) where l = snd $ itemToBreakLists (t ^. dtValue . _1) (t ^. dtValue . _2) - f x y = tail $ dropWhile ((/=y)) x + f x y = tail $ dropWhile (/=y) x -leftRightCombine :: - DTComb a -> - DTComb a -> - DTree a -> - DTree a -> - Maybe (DTree a) +leftRightCombine :: DTComb a -> DTComb a -> DTree a -> DTree a -> Maybe (DTree a) leftRightCombine f f' t1 t2 = f t1 t2 <|> checkdepth t1 t2 where checkdepth t t'@(DT x ls rs) = fromMaybe (checktop t t') $ do - (t'') <- safeHead ls + t'' <- safeHead ls tx <- checkdepth t t'' - return $ Just $ DT x (( tx) : tail ls) rs + return $ Just $ DT x (tx : tail ls) rs checktop t t' = f' t t' joinItemsInList :: (a -> a -> Maybe a) -> [a] -> [a] diff --git a/src/Dodge/Item/HeldOffset.hs b/src/Dodge/Item/HeldOffset.hs index 525f644bf..256d7747e 100644 --- a/src/Dodge/Item/HeldOffset.hs +++ b/src/Dodge/Item/HeldOffset.hs @@ -56,7 +56,7 @@ handOrient cr = case cr ^. crStance . posture of locOrient :: LocationDT OItem -> Creature -> Point3Q locOrient loc cr = - handHandleOrient (fmap (\(x, y, _) -> (x, y)) $ locToTop' loc) cr + handHandleOrient ((\(x, y, _) -> (x, y)) <$> locToTop' loc) cr `Q.comp` (loc ^. locDT . dtValue . _3) handHandleOrient :: LocationDT CItem -> Creature -> Point3Q diff --git a/src/Dodge/Item/Orientation.hs b/src/Dodge/Item/Orientation.hs index 604ace822..1eaf3f086 100644 --- a/src/Dodge/Item/Orientation.hs +++ b/src/Dodge/Item/Orientation.hs @@ -1,6 +1,5 @@ module Dodge.Item.Orientation ( orientAttachment, --- propagateOrientation, propagateOrientation', ) where @@ -40,12 +39,6 @@ orientAttachment par (ch,chsf) = case (_itType par, chsf) of (t1, q1) = orientByParentChSF par chsf (t2, q2) = orientChild ch ---propagateOrientation :: LDTree ItemLink CItem -> LDTree ItemLink OItem ---propagateOrientation = ldtStartPropagate g f --- where --- g (x,y) = (x,y,(V3 0 0 0,Q.qID)) --- f (x,_,pq) _ (y,y1) = (y,y1,Q.comp pq $ orientAttachment x (y,y1)) - propagateOrientation' :: DTree CItem -> DTree OItem propagateOrientation' = dtStartPropagate g f where