Description
enumerate all the values in a finite type (automatically)
Description
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.
see the Enumerable
module for extensive documentation.
README.md
enumerate
Enumerate all the values in a finite type (automatically). Provides:
- a typeclass for enumerating all values in a finite type,
- a generic instance for automatically deriving it, and
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]
(extensive) documentation:
https://hackage.haskell.org/package/enumerate/docs/Enumerate.html
http://sboosali.github.io/documentation/enumerate/Enumerate.html (when hackage won't build the haddocks)
related:
To reify functions, partial or total, into a Map, see enumerate-function.