diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2019-06-08 20:48:07 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-06-12 07:37:12 -0400 |
commit | 1219f8e8a3d1b58263bea76822322b746a632778 (patch) | |
tree | bd93bdf1e09cd26a7c6104ba37c6734a74e8a7bc /compiler/utils/OrdList.hs | |
parent | 217e6db4af6752b13c586d4e8925a4a9a2f47245 (diff) | |
download | haskell-1219f8e8a3d1b58263bea76822322b746a632778.tar.gz |
Use DeriveFunctor throughout the codebase (#15654)
Diffstat (limited to 'compiler/utils/OrdList.hs')
-rw-r--r-- | compiler/utils/OrdList.hs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs index 2d7a43f228..e8b50e5968 100644 --- a/compiler/utils/OrdList.hs +++ b/compiler/utils/OrdList.hs @@ -8,6 +8,7 @@ This is useful, general stuff for the Native Code Generator. Provide trees (of instructions), so that lists of instructions can be appended in linear time. -} +{-# LANGUAGE DeriveFunctor #-} module OrdList ( OrdList, @@ -34,6 +35,7 @@ data OrdList a | Snoc (OrdList a) a | Two (OrdList a) -- Invariant: non-empty (OrdList a) -- Invariant: non-empty + deriving (Functor) instance Outputable a => Outputable (OrdList a) where ppr ol = ppr (fromOL ol) -- Convert to list and print that @@ -46,9 +48,6 @@ instance Monoid (OrdList a) where mappend = (Semigroup.<>) mconcat = concatOL -instance Functor OrdList where - fmap = mapOL - instance Foldable OrdList where foldr = foldrOL @@ -117,12 +116,7 @@ fromOLReverse a = go a [] go (Many xs) acc = reverse xs ++ acc mapOL :: (a -> b) -> OrdList a -> OrdList b -mapOL _ None = None -mapOL f (One x) = One (f x) -mapOL f (Cons x xs) = Cons (f x) (mapOL f xs) -mapOL f (Snoc xs x) = Snoc (mapOL f xs) (f x) -mapOL f (Two x y) = Two (mapOL f x) (mapOL f y) -mapOL f (Many xs) = Many (map f xs) +mapOL = fmap foldrOL :: (a->b->b) -> b -> OrdList a -> b foldrOL _ z None = z |