nikita-volkov / typeclasses / Typeclasses.Extensions.Maybe

Extensions to the Maybe API, which utilise typeclasses.

fold : Typeclasses.Classes.Monoid.Monoid a -> Maybe a -> a

Extract a value or use the Monoid's identity.

foldMap : Typeclasses.Classes.Monoid.Monoid b -> (a -> b) -> Maybe a -> b

Map the element of Maybe to a type which has an instance of Monoid, or use its identity, when Maybe is Nothing.