[Haskell-cafe] ANN: generic-maybe-

Jonathan Fischoff jonathangfischoff at gmail.com
Wed Feb 12 04:51:38 UTC 2014

generic-maybe utilizes GHC.Generics to generalize the functions of
Data.Maybe to arbitrary sum types with two constructors, with one "empty."

Here is a quick example:

λ> :set -XDeriveGeneric
λ> import GHC.Generics

λ> data Result a = Success a | Fail deriving (Show, Generic)

λ> fromMaybe 'a' Fail
λ> fromMaybe 'a' $ Success 'b'

Additionally, it lets you convert between two representations:

λ> convert (Just 'a') :: Result Char
 Success 'a'

Documentation on Hackage:

-Jonathan Fischoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140211/2c77898d/attachment.html>

More information about the Haskell-Cafe mailing list