universe-base-1.1.3: A class for finite and recursively enumerable types.
Safe Haskell Safe
Language Haskell2010

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

Instances

Instances details
Universe Bool Source #
Instance details

Defined in Data.Universe.Class

Universe Char Source #
Instance details

Defined in Data.Universe.Class

Universe Int Source #
Instance details

Defined in Data.Universe.Class

Universe Int8 Source #
Instance details

Defined in Data.Universe.Class

Universe Int16 Source #
Instance details

Defined in Data.Universe.Class

Universe Int32 Source #
Instance details

Defined in Data.Universe.Class

Universe Int64 Source #
Instance details

Defined in Data.Universe.Class

Universe Integer Source #
Instance details

Defined in Data.Universe.Class

Universe Natural Source #
Instance details

Defined in Data.Universe.Class

Universe Ordering Source #
Instance details

Defined in Data.Universe.Class

Universe Word Source #
Instance details

Defined in Data.Universe.Class

Universe Word8 Source #
Instance details

Defined in Data.Universe.Class

Universe Word16 Source #
Instance details

Defined in Data.Universe.Class

Universe Word32 Source #
Instance details

Defined in Data.Universe.Class

Universe Word64 Source #
Instance details

Defined in Data.Universe.Class

Universe () Source #
Instance details

Defined in Data.Universe.Class

Methods

universe :: [()] Source #

Universe Void Source #
Instance details

Defined in Data.Universe.Class

Universe All Source #
Instance details

Defined in Data.Universe.Class

Universe Any Source #
Instance details

Defined in Data.Universe.Class

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

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

( 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

( 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

( 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

( 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

( 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

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

( 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

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

Defined in Data.Universe.Class

( 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

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 ( Solo 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

( 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

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

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

( 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

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class