@hackage generic-maybe0.3.0.2

A generic version of Data.Maybe

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 you 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'