Commit eaed140c authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

OrdList: Add Foldable, Traversable instances

Test Plan: Validate

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2740
parent 6d5c2e7b
......@@ -49,6 +49,15 @@ instance Monoid (OrdList a) where
mappend = appOL
mconcat = concatOL
instance Functor OrdList where
fmap = mapOL
instance Foldable OrdList where
foldr = foldrOL
instance Traversable OrdList where
traverse f xs = toOL <$> traverse f (fromOL xs)
nilOL :: OrdList a
isNilOL :: OrdList a -> Bool
......@@ -98,9 +107,6 @@ 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)
instance Functor OrdList where
fmap = mapOL
foldrOL :: (a->b->b) -> b -> OrdList a -> b
foldrOL _ z None = z
foldrOL k z (One x) = k x z
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment