universe-base-1.1.4: A class for finite and recursively enumerable types.

Safe Haskell | Safe
Language | Haskell2010

Data.Universe.Generic

Synopsis

- class GUniverse (f :: Type -> Type) where
  - guniverse :: [f a]
- class GUniverseSum (f :: Type -> Type) where
  - guniverseSum :: [[f a]]
- class GUniverseProduct (f :: Type -> Type) where
  - guniverseProduct :: [f a]
- universeGeneric :: (Generic a, GUniverse (Rep a)) => [a]

# Documentation

    >>> :set -XDeriveGeneric
    >>> import GHC.Generics

class GUniverse (f :: Type -> Type) where Source #

Methods

guniverse :: [f a] Source #

#### Instances

Instances details

GUniverseSum f => GUniverse (M1 i c f) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverse :: [M1 i c f a] Source #

class GUniverseSum (f :: Type -> Type) where Source #

Methods

guniverseSum :: [[f a]] Source #

#### Instances

Instances details

GUniverseSum (V1 :: Type -> Type) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseSum :: [[V1 a]] Source #
(GUniverseSum f, GUniverseSum g) => GUniverseSum (f :+: g) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseSum :: [[(f :+: g) a]] Source #
GUniverseProduct f => GUniverseSum (M1 i c f) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseSum :: [[M1 i c f a]] Source #

class GUniverseProduct (f :: Type -> Type) where Source #

Methods

guniverseProduct :: [f a] Source #

#### Instances

Instances details

GUniverseProduct (U1 :: Type -> Type) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseProduct :: [U1 a] Source #
(GUniverseProduct f, GUniverseProduct g) => GUniverseProduct (f :*: g) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseProduct :: [(f :*: g) a] Source #
Universe a => GUniverseProduct (K1 r a :: Type -> Type) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseProduct :: [K1 r a a0] Source #
GUniverseProduct f => GUniverseProduct (M1 i c f) Source # |
Instance details Defined in Data.Universe.Generic Methods guniverseProduct :: [M1 i c f a] Source #

universeGeneric :: (Generic a, GUniverse (Rep a)) => [a] Source #

    >>> data One = One deriving (Show, Generic)
    >>> universeGeneric :: [One]
    [One]

    >>> data Big = B0 Bool Bool | B1 Bool deriving (Show, Generic)
    >>> universeGeneric :: [Big]
    [B0 False False,B1 False,B0 False True,B1 True,B0 True False,B0 True True]

    >>> universeGeneric :: [Maybe Ordering]
    [Nothing,Just LT,Just EQ,Just GT]

    >>> take 10 (universeGeneric :: [Either Integer Integer])
    [Left 0,Right 0,Left 1,Right 1,Left (-1),Right (-1),Left 2,Right 2,Left (-2),Right (-2)]

    >>> take 10 (universeGeneric :: [(Integer, Integer, Integer)])
    [(0,0,0),(0,0,1),(1,0,0),(0,1,0),(1,0,1),(-1,0,0),(0,0,-1),(1,1,0),(-1,0,1),(2,0,0)]

    >>> :set -XEmptyDataDeriving

    >>> data Zero deriving (Show, Generic)
    >>> universeGeneric :: [Zero]
    []