Skip to content

fpringle/generic-case

Repository files navigation

Generic case analysis functions

"Case analysis" functions are those which take one function for each constructor of a sum type, examine a value of that type, and call the relevant function depending on which constructor was used to build that type. Examples include maybe, either and bool. generic-case gives you these functions for any type which implements Generic from generics-sop.

maybe :: forall a r. r -> (a -> r) -> Maybe a -> r
maybe = gcaseR @(Maybe a)

For more detailed documentation, see Generics.Case.

About

Generic case analysis using generics-sop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published