Popularity
3.9
Declining
Activity
0.0
Stable
5
4
0

Monthly Downloads: 14
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Generic     Generics    

generic-maybe alternatives and similar packages

Based on the "generic" category.
Alternatively, view generic-maybe alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of generic-maybe or a related project?

Add another 'generic' Package

README

Build Status

This module is a drop in replacement for '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.

{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics

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

After which you can use the functions, like your type was 'Maybe'

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