universe-base-1.1.2: A class for finite and recursively enumerable types.
Safe HaskellSafe
LanguageHaskell2010

Data.Universe.Class

Description

Bottoms are ignored for this entire module: only fully-defined inhabitants are considered inhabitants.

Synopsis

Documentation

class Universe a where Source #

Creating an instance of this class is a declaration that your type is recursively enumerable (and that universe is that enumeration). In particular, you promise that any finite inhabitant has a finite index in universe, and that no inhabitant appears at two different finite indices.

Well-behaved instance should produce elements lazily.

Laws:

elem x universe                    -- any inhabitant has a finite index
let pfx = take n universe          -- any finite prefix of universe has unique elements
in length pfx = length (nub pfx)

Minimal complete definition

Nothing

Methods

universe :: [a] Source #

default universe :: (Enum a, Bounded a) => [a] Source #

Instances

Instances details
Universe Bool Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Bool] Source #

Universe Char Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Char] Source #

Universe Int Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int] Source #

Universe Int8 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int8] Source #

Universe Int16 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int16] Source #

Universe Int32 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int32] Source #

Universe Int64 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int64] Source #

Universe Integer Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Integer] Source #

Universe Natural Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Natural] Source #

Universe Ordering Source # 
Instance details

Defined in Data.Universe.Class

Universe Word Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word] Source #

Universe Word8 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word8] Source #

Universe Word16 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word16] Source #

Universe Word32 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word32] Source #

Universe Word64 Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word64] Source #

Universe () Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [()] Source #

Universe Void Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Void] Source #

Universe All Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [All] Source #

Universe Any Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Any] Source #

Universe a => Universe [a] Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [[a]] Source #

Universe a => Universe (Maybe a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Maybe a] Source #

RationalUniverse a => Universe (Ratio a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Ratio a] Source #

Universe a => Universe (Min a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Min a] Source #

Universe a => Universe (Max a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Max a] Source #

Universe a => Universe (First a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [First a] Source #

Universe a => Universe (Last a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Last a] Source #

Universe a => Universe (Identity a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Identity a] Source #

Universe a => Universe (First a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [First a] Source #

Universe a => Universe (Last a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Last a] Source #

Universe a => Universe (Dual a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Dual a] Source #

Universe a => Universe (Sum a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Sum a] Source #

Universe a => Universe (Product a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Product a] Source #

Universe a => Universe (NonEmpty a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [NonEmpty a] Source #

(Ord a, Universe a) => Universe (Set a) Source #
>>> import qualified Data.Set as Set
>>> mapM_ print (universe :: [Set.Set Bool])
fromList []
fromList [False]
fromList [True]
fromList [False,True]
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Set a] Source #

(Finite a, Ord a, Universe b) => Universe (a -> b) Source #
>>> mapM_ print (universe :: [Bool -> Bool])
[(False,False),(True,False)]
[(False,False),(True,True)]
[(False,True),(True,False)]
[(False,True),(True,True)]
Instance details

Defined in Data.Universe.Class

Methods

universe :: [a -> b] Source #

(Universe a, Universe b) => Universe (Either a b) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Either a b] Source #

(Universe a, Universe b) => Universe (a, b) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [(a, b)] Source #

Universe (Proxy a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Proxy a] Source #

(Ord k, Finite k, Universe v) => Universe (Map k v) Source #
>>> import qualified Data.Map as Map
>>> mapM_ print (universe :: [Map.Map Bool Bool])
fromList []
fromList [(True,False)]
fromList [(False,False)]
fromList [(True,True)]
fromList [(False,False),(True,False)]
fromList [(False,True)]
fromList [(False,False),(True,True)]
fromList [(False,True),(True,False)]
fromList [(False,True),(True,True)]
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Map k v] Source #

(Universe a, Universe b, Universe c) => Universe (a, b, c) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [(a, b, c)] Source #

Universe a => Universe (Const a b) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Const a b] Source #

Universe a => Universe (Tagged b a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Tagged b a] Source #

(Finite e, Ord e, Universe (m a)) => Universe (ReaderT e m a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [ReaderT e m a] Source #

Universe (f a) => Universe (IdentityT f a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [IdentityT f a] Source #

(Universe a, Universe b, Universe c, Universe d) => Universe (a, b, c, d) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [(a, b, c, d)] Source #

(Universe (f a), Universe (g a)) => Universe (Product f g a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Product f g a] Source #

(Universe (f a), Universe (g a)) => Universe (Sum f g a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Sum f g a] Source #

(Universe a, Universe b, Universe c, Universe d, Universe e) => Universe (a, b, c, d, e) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [(a, b, c, d, e)] Source #

Universe (f (g a)) => Universe (Compose f g a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Compose f g a] Source #

class Universe a => Finite a where Source #

Creating an instance of this class is a declaration that your universe eventually ends. Minimal definition: no methods defined. By default, universeF = universe, but for some types (like Either) the universeF method may have a more intuitive ordering.

Laws:

elem x universeF                       -- any inhabitant has a finite index
length (filter (== x) universeF) == 1  -- should terminate
(xs -> cardinality xs == genericLength xs) universeF

Note: elemIndex x universe == elemIndex x universeF may not hold for all types, though the laws imply that universe is a permutation of universeF.

>>> elemIndex (Left True :: Either Bool Bool) universe
Just 2
>>> elemIndex (Left True :: Either Bool Bool) universeF
Just 1

Minimal complete definition

Nothing

Instances

Instances details
Finite Bool Source # 
Instance details

Defined in Data.Universe.Class

Finite Char Source # 
Instance details

Defined in Data.Universe.Class

Finite Int Source # 
Instance details

Defined in Data.Universe.Class

Finite Int8 Source # 
Instance details

Defined in Data.Universe.Class

Finite Int16 Source # 
Instance details

Defined in Data.Universe.Class

Finite Int32 Source # 
Instance details

Defined in Data.Universe.Class

Finite Int64 Source # 
Instance details

Defined in Data.Universe.Class

Finite Ordering Source # 
Instance details

Defined in Data.Universe.Class

Finite Word Source # 
Instance details

Defined in Data.Universe.Class

Finite Word8 Source # 
Instance details

Defined in Data.Universe.Class

Finite Word16 Source # 
Instance details

Defined in Data.Universe.Class

Finite Word32 Source # 
Instance details

Defined in Data.Universe.Class

Finite Word64 Source # 
Instance details

Defined in Data.Universe.Class

Finite () Source # 
Instance details

Defined in Data.Universe.Class

Finite Void Source # 
Instance details

Defined in Data.Universe.Class

Finite All Source # 
Instance details

Defined in Data.Universe.Class

Finite Any Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Maybe a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Min a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Max a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (First a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Last a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Identity a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (First a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Last a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Dual a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Sum a) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Product a) Source # 
Instance details

Defined in Data.Universe.Class

(Ord a, Finite a) => Finite (Set a) Source # 
Instance details

Defined in Data.Universe.Class

(Ord a, Finite a, Finite b) => Finite (a -> b) Source #
>>> mapM_ print (universeF :: [Bool -> Bool])
[(False,False),(True,False)]
[(False,False),(True,True)]
[(False,True),(True,False)]
[(False,True),(True,True)]
>>> cardinality :: Tagged (Bool -> Ordering) Natural
Tagged 9
>>> cardinality :: Tagged (Ordering -> Bool) Natural
Tagged 8
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [a -> b] Source #

cardinality :: Tagged (a -> b) Natural Source #

(Finite a, Finite b) => Finite (Either a b) Source # 
Instance details

Defined in Data.Universe.Class

(Finite a, Finite b) => Finite (a, b) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [(a, b)] Source #

cardinality :: Tagged (a, b) Natural Source #

Finite (Proxy a) Source # 
Instance details

Defined in Data.Universe.Class

(Ord k, Finite k, Finite v) => Finite (Map k v) Source # 
Instance details

Defined in Data.Universe.Class

(Finite a, Finite b, Finite c) => Finite (a, b, c) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [(a, b, c)] Source #

cardinality :: Tagged (a, b, c) Natural Source #

Finite a => Finite (Const a b) Source # 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Tagged b a) Source # 
Instance details

Defined in Data.Universe.Class

(Finite e, Ord e, Finite (m a)) => Finite (ReaderT e m a) Source # 
Instance details

Defined in Data.Universe.Class

Finite (f a) => Finite (IdentityT f a) Source # 
Instance details

Defined in Data.Universe.Class

(Finite a, Finite b, Finite c, Finite d) => Finite (a, b, c, d) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [(a, b, c, d)] Source #

cardinality :: Tagged (a, b, c, d) Natural Source #

(Finite (f a), Finite (g a)) => Finite (Product f g a) Source # 
Instance details

Defined in Data.Universe.Class

(Finite (f a), Finite (g a)) => Finite (Sum f g a) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [Sum f g a] Source #

cardinality :: Tagged (Sum f g a) Natural Source #

(Finite a, Finite b, Finite c, Finite d, Finite e) => Finite (a, b, c, d, e) Source # 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [(a, b, c, d, e)] Source #

cardinality :: Tagged (a, b, c, d, e) Natural Source #

Finite (f (g a)) => Finite (Compose f g a) Source # 
Instance details

Defined in Data.Universe.Class