@hackage generic-maybe0.3.0.4
A generic version of Data.Maybe
Installation
CustomDependencies (2)
Dependents (1)
@hackage/acme-everything
Package Flags
test-doctests(on by default)
test-hlint(on by default)
This module is a drop in replacement for Data.Maybe. It generalizes
the functions to any types that share the same "sum of products" view
of Maybe.
To use the module for your type, enable GHC's DeriveGeneric extension and derive a Generic instance for your type.
import GHC.Generics data Result a = Success a | Fail deriving (Show, Generic)
After which you can use the functions, like your type was Data.Maybe.Maybe
> fromMaybe 'a' Fail 'a'
> fromMaybe 'a' $ Success 'b' 'b'