About

Metadata

  • Last updated , by JonathanFischoff
  • License BSD-3-Clause
  • Categories Generics
  • Maintained by: jonathangfischoff@gmail.com

  • Lottery factor: 0

Links

Installation

This package uses the Custom cabal build type

Package Flags

Use the -f option with cabal commands to enable flags

    test-doctests (on by default)
    test-hlint (on by default)

Readme

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'