Commit bf1e1f32 authored by David Feuer's avatar David Feuer Committed by David Feuer
Browse files

Add explicit foldMap implementation for Maybe

Eric Mertens pointed out that using the default `foldMap`
implementation for `Maybe` led to an efficiency problem by
implementing `foldMap f (Just x)` as `f x <> mempty` rather than
as `f x`. This should solve the problem.

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: glguy, thomie

Differential Revision: https://phabricator.haskell.org/D2988
parent f07a6c17
......@@ -270,6 +270,8 @@ class Foldable t where
-- | @since 2.01
instance Foldable Maybe where
foldMap = maybe mempty
foldr _ z Nothing = z
foldr f z (Just x) = f 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