generic-deriving-1.4.0: Generic programming library for generalised deriving.

Safe Haskell | Safe-Inferred

Generics.Deriving.Enum

Contents

- Generic enum class
- Default definitions for GEnum
- Generic Ix class
- Default definitions for GIx

Synopsis

- class GEnum a where
  - genum :: [a]
- genumDefault :: (Generic a, Enum' (Rep a)) => [a]
- toEnumDefault :: (Generic a, Enum' (Rep a)) => Int -> a
- fromEnumDefault :: (GEq a, Generic a, Enum' (Rep a)) => a -> Int
- class Ord a => GIx a where
  - range :: (a, a) -> [a]
  - index :: (a, a) -> a -> Int
  - inRange :: (a, a) -> a -> Bool
- rangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
- indexDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
- inRangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool

# Generic enum class

class GEnum a where Source

Methods

genum :: [a]Source

Instances

GEnum Int |
GEnum a => GEnum [a] |
GEnum a => GEnum (Maybe a) |

# Default definitions for GEnum

genumDefault :: (Generic a, Enum' (Rep a)) => [a]Source

toEnumDefault :: (Generic a, Enum' (Rep a)) => Int -> aSource

fromEnumDefault :: (GEq a, Generic a, Enum' (Rep a)) => a -> Int Source

# Generic Ix class

class Ord a => GIx a where Source

Methods

range :: (a, a) -> [a]Source

The list of values in the subrange defined by a bounding pair.

index :: (a, a) -> a -> Int Source

The position of a subscript in the subrange.

inRange :: (a, a) -> a -> Bool Source

Returns `True` the given subscript lies in the range defined the bounding pair.

Instances

GIx Int |
(GEq a, GEnum a, GIx a) => GIx [a] |
(GEq a, GEnum a, GIx a) => GIx (Maybe a) |

# Default definitions for GIx

rangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]Source

indexDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int Source

inRangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool Source