Skip to content

Commit 7de1ca4

Browse files
committed
Fix foldr implementation
1 parent b2b8d2c commit 7de1ca4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

chapter-21/laws/app/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ instance Traversable (List) where
124124
traverse f (Cons a rest) = liftA2 (Cons) (f a) (traverse f rest)
125125

126126
instance Foldable List where
127-
{-TODO cannot make this to work if foldMap below is commented-}
128127
foldr f d Nil = d
129-
foldr f d (Cons x rest) = foldr f (f x d) rest
128+
foldr f d (Cons x rest) = f x (foldr f d rest)
130129

131130
foldMap ctor (Nil) = mempty
132131
foldMap ctor (Cons x rest) = ctor x `mappend` (foldMap ctor rest)

0 commit comments

Comments
 (0)