Skip to content

Commit

Permalink
Foldable & Traversable for Id
Browse files Browse the repository at this point in the history
Ignore-this: 8a7ae889667ea7a6bb8f8b71c338160b

darcs-hash:20110226002430-fb517-806574abb4fe192984bfd754b080f44220e1557c.gz
  • Loading branch information
conal committed Feb 26, 2011
1 parent 4c44991 commit 22b4d34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Control/Compose.hs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ instance (Applicative f, Monoid m) => Monoid (App f m) where


{----------------------------------------------------------
Identity -- TODO: eliminate in favor of Data.Traversable.Id
Identity
----------------------------------------------------------}

-- | Identity type constructor. Until there's a better place to find it.
Expand Down Expand Up @@ -618,6 +618,16 @@ instance Applicative Id where
pure = Id
(<*>) = inId2 ($)

instance Foldable Id where
foldMap f (Id a) = f a

instance Traversable Id where
sequenceA (Id fa) = fmap Id fa

-- Id fa :: Id (f a)
-- fa :: f a
-- fmap Id fa = f (Id a)

{----------------------------------------------------------
Unary constructor pairing
----------------------------------------------------------}
Expand Down

0 comments on commit 22b4d34

Please sign in to comment.