fin-0.1.1: Nat and Fin: peano naturals and finite numbers
Safe Haskell None
Language Haskell2010

Data.Fin.Enum

Description

This module is designed to be imported qualified:

import qualified Data.Fin.Enum as E
Synopsis

Documentation

class Enum a where Source #

Generic enumerations.

Examples:

>>> from ()
0
>>> to 0 :: ()
()
>>> to 0 :: Bool
False
>>> map to F.universe :: [Bool]
[False,True]
>>> map (to . (+1) . from) [LT, EQ, GT] :: [Ordering] -- Num Fin is modulo arithmetic
[EQ,GT,LT]

Minimal complete definition

Nothing

Associated Types

type EnumSize a :: Nat Source #

The size of an enumeration.

Methods

from :: a -> Fin ( EnumSize a) Source #

Converts a value to its index.

to :: Fin ( EnumSize a) -> a Source #

Converts from index to the original value.

Generic implementation

gfrom :: ( Generic a, GFrom a) => a -> Fin ( GEnumSize a) Source #

Generic version of from .

type GFrom a = GFromRep ( Rep a) Source #

Constraint for the class that computes gfrom .

gto :: ( Generic a, GTo a) => Fin ( GEnumSize a) -> a Source #

Generic version of to .

type GTo a = GToRep ( Rep a) Source #

Constraint for the class that computes gto .

type GEnumSize a = EnumSizeRep ( Rep a) Nat0 Source #

Compute the size from the type.