@hackage / enumerate

enumerate all the values in a finite type (automatically)

Latest0.2.2

About

Metadata

  • Last updated , by sboo
  • License MIT
  • Maintained by: samboosalis@gmail.com

  • Lottery factor: 0

Links

Installation

Package Flags

Use the -f option with cabal commands to enable flags

    dump-core (off by default)

    Dump HTML for the core generated by GHC during compilation

Readme

enumerate

Hackage Build Status

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 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)

To reify functions, partial or total, into a Map, see enumerate-function.