generic-case: Generic case analysis

[ bsd3, generics, library ] [ Propose Tags ] [ Report a vulnerability ]

Generic case analysis in the vein of maybe, either and bool, using generics-sop.

See the module documentation in Generics.Case.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.1.1
Change log CHANGELOG.md
Dependencies base (>=4 && <5), generics-sop (>=0.4 && <0.6), sop-core (>=0.4.0.1 && <0.6) [details]
Tested with ghc ==9.12.2, ghc ==9.10.1, ghc ==9.8.2, ghc ==9.6.5, ghc ==9.4.8, ghc ==9.2.8, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.6.5
License BSD-3-Clause
Copyright Copyright(c) Frederick Pringle 2025
Author Frederick Pringle
Maintainer freddyjepringle@gmail.com
Category Generics
Home page https://github.com/fpringle/generic-case
Source repo head: git clone https://github.com/fpringle/generic-case.git
Uploaded by fpringle at 2025-05-30T12:34:03Z
Distributions Stackage:0.1.1.0
Downloads 21 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for generic-case-0.1.1.1

[back to package description]

Haskell CI

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.