@hackage enumerate0.2.1
enumerate all the values in a finite type (automatically)
Categories
License
MIT
Maintainer
samboosalis@gmail.com
Links
Versions
Installation
Dependencies (7)
- array >=0.5 && <0.6
- base >=4.7 && <5
- containers >=0.5 && <0.6
- deepseq >=1.3
- ghc-prim >=0.3 && <0.5
- template-haskell >=2.9 Show all…
Dependents (1)
@hackage/enumerate-function
enumerate
enumerate all the values in a finite type (automatically)
provides (1) a typeclass for enumerating all values in a finite type, (2) a generic instance for automatic deriving, and (3) helpers that reify functions (partial or total, monadic or pure) into a Map.
example
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
import Data.Enumerate (Enumerable(..))
import Data.Generics (Generics)
data CrudOp = Add | Edit | Delete | View
deriving (Eq,Ord,Enum,Bounded,Generic,Enumerable)
data Route = Home | Person CrudOp | House CrudOp
deriving (Eq,Ord,Generic,Enumerable)
>>> enumerated :: [Route]
[Home, Person Add, Person Edit, Person Delete, Person View, House Add, House Edit, House Delete, House View]