universe-instances-extended-1.1.2: Universe instances for types from selected extra packages
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Universe.Instances.Extended

Synopsis

Documentation

Instances for Universe and Finite for function-like functors and the empty type.

class Universe a where #

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] #

Instances

Instances details
Universe Bool 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Bool] #

Universe Char 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Char] #

Universe Int 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int] #

Universe Int8 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int8] #

Universe Int16 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int16] #

Universe Int32 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int32] #

Universe Int64 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Int64] #

Universe Integer 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Integer] #

Universe Natural 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Natural] #

Universe Ordering 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Ordering] #

Universe Word 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word] #

Universe Word8 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word8] #

Universe Word16 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word16] #

Universe Word32 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word32] #

Universe Word64 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Word64] #

Universe () 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [()] #

Universe Void 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Void] #

Universe All 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [All] #

Universe Any 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Any] #

Universe a => Universe [a] 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [[a]] #

Universe a => Universe (Maybe a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Maybe a] #

RationalUniverse a => Universe (Ratio a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Ratio a] #

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

Defined in Data.Universe.Instances.Extended

Methods

universe :: [Predicate a] #

Universe a => Universe (Min a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Min a] #

Universe a => Universe (Max a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Max a] #

Universe a => Universe (First a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [First a] #

Universe a => Universe (Last a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Last a] #

Universe a => Universe (Identity a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Identity a] #

Universe a => Universe (First a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [First a] #

Universe a => Universe (Last a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Last a] #

Universe a => Universe (Dual a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Dual a] #

Universe a => Universe (Sum a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Sum a] #

Universe a => Universe (Product a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Product a] #

Universe a => Universe (NonEmpty a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [NonEmpty a] #

(Ord a, Universe a) => Universe (Set a)
>>> 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] #

(Finite a, Ord a, Universe b) => Universe (a -> b)
>>> 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] #

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

Defined in Data.Universe.Class

Methods

universe :: [Either a b] #

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

Defined in Data.Universe.Class

Methods

universe :: [(a, b)] #

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

Defined in Data.Universe.Instances.Extended

Methods

universe :: [Op a b] #

(Representable f, Finite (Rep f), Ord (Rep f), Universe a) => Universe (Co f a) Source #

We could do this:

instance Universe (f a) => Universe (Co f a) where universe = map Rep universe

However, since you probably only apply Rep to functors when you want to think of them as being representable, I think it makes sense to use an instance based on the representable-ness rather than the inherent universe-ness.

Please complain if you disagree!

Instance details

Defined in Data.Universe.Instances.Extended

Methods

universe :: [Co f a] #

Universe (Proxy a) 
Instance details

Defined in Data.Universe.Class

Methods

universe :: [Proxy a] #

(Ord k, Finite k, Universe v) => Universe (Map k v)
>>> 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] #

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

Defined in Data.Universe.Class

Methods

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

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

Defined in Data.Universe.Class

Methods

universe :: [Const a b] #

(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Universe a) => Universe (TracedT s f a) Source # 
Instance details

Defined in Data.Universe.Instances.Extended

Methods

universe :: [TracedT s f a] #

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

Defined in Data.Universe.Class

Methods

universe :: [IdentityT f a] #

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

Defined in Data.Universe.Class

Methods

universe :: [ReaderT e m a] #

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

Defined in Data.Universe.Class

Methods

universe :: [Tagged b a] #

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

Defined in Data.Universe.Class

Methods

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

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

Defined in Data.Universe.Class

Methods

universe :: [Product f g a] #

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

Defined in Data.Universe.Class

Methods

universe :: [Sum f g a] #

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

Defined in Data.Universe.Class

Methods

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

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

Defined in Data.Universe.Class

Methods

universe :: [Compose f g a] #

class Universe a => Finite a where #

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 
Instance details

Defined in Data.Universe.Class

Finite Char 
Instance details

Defined in Data.Universe.Class

Finite Int 
Instance details

Defined in Data.Universe.Class

Finite Int8 
Instance details

Defined in Data.Universe.Class

Finite Int16 
Instance details

Defined in Data.Universe.Class

Finite Int32 
Instance details

Defined in Data.Universe.Class

Finite Int64 
Instance details

Defined in Data.Universe.Class

Finite Ordering 
Instance details

Defined in Data.Universe.Class

Finite Word 
Instance details

Defined in Data.Universe.Class

Finite Word8 
Instance details

Defined in Data.Universe.Class

Finite Word16 
Instance details

Defined in Data.Universe.Class

Finite Word32 
Instance details

Defined in Data.Universe.Class

Finite Word64 
Instance details

Defined in Data.Universe.Class

Finite () 
Instance details

Defined in Data.Universe.Class

Methods

universeF :: [()] #

cardinality :: Tagged () Natural #

Finite Void 
Instance details

Defined in Data.Universe.Class

Finite All 
Instance details

Defined in Data.Universe.Class

Finite Any 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Maybe a) 
Instance details

Defined in Data.Universe.Class

(Finite a, Ord a) => Finite (Predicate a) Source #
>>> mapM_ print (universe :: [Predicate Ordering])
Predicate {getPredicate = [(LT,False),(EQ,False),(GT,False)]}
Predicate {getPredicate = [(LT,True),(EQ,False),(GT,False)]}
Predicate {getPredicate = [(LT,False),(EQ,True),(GT,False)]}
Predicate {getPredicate = [(LT,True),(EQ,True),(GT,False)]}
Predicate {getPredicate = [(LT,False),(EQ,False),(GT,True)]}
Predicate {getPredicate = [(LT,True),(EQ,False),(GT,True)]}
Predicate {getPredicate = [(LT,False),(EQ,True),(GT,True)]}
Predicate {getPredicate = [(LT,True),(EQ,True),(GT,True)]}

Beware, function type universes are large...

>>> cardinality :: Tagged (Predicate Int8) Natural
Tagged 115792089237316195423570985008687907853269984665640564039457584007913129639936

... but thanks to laziness, you can expect at least few:

>>> let Predicate f : _ = universe :: [Predicate Int8]
>>> f 0
False
Instance details

Defined in Data.Universe.Instances.Extended

Finite a => Finite (Min a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Max a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (First a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Last a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Identity a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (First a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Last a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Dual a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Sum a) 
Instance details

Defined in Data.Universe.Class

Finite a => Finite (Product a) 
Instance details

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

(Ord a, Finite a, Finite b) => Finite (a -> b)
>>> 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] #

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

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

Methods

universeF :: [(a, b)] #

cardinality :: Tagged (a, b) Natural #

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

Defined in Data.Universe.Instances.Extended

Methods

universeF :: [Op a b] #

cardinality :: Tagged (Op a b) Natural #

(Representable f, Finite (Rep f), Ord (Rep f), Finite a) => Finite (Co f a) Source # 
Instance details

Defined in Data.Universe.Instances.Extended

Methods

universeF :: [Co f a] #

cardinality :: Tagged (Co f a) Natural #

Finite (Proxy a) 
Instance details

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

Methods

universeF :: [Map k v] #

cardinality :: Tagged (Map k v) Natural #

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

Defined in Data.Universe.Class

Methods

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

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

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

Defined in Data.Universe.Class

Methods

universeF :: [Const a b] #

cardinality :: Tagged (Const a b) Natural #

(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Finite a) => Finite (TracedT s f a) Source # 
Instance details

Defined in Data.Universe.Instances.Extended

Methods

universeF :: [TracedT s f a] #

cardinality :: Tagged (TracedT s f a) Natural #

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

Methods

universeF :: [ReaderT e m a] #

cardinality :: Tagged (ReaderT e m a) Natural #

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

Defined in Data.Universe.Class

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

Defined in Data.Universe.Class

Methods

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

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

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

Defined in Data.Universe.Class

Methods

universeF :: [Product f g a] #

cardinality :: Tagged (Product f g a) Natural #

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

Defined in Data.Universe.Class

Methods

universeF :: [Sum f g a] #

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

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

Defined in Data.Universe.Class

Methods

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

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

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

Defined in Data.Universe.Class

Methods

universeF :: [Compose f g a] #

cardinality :: Tagged (Compose f g a) Natural #

Orphan instances

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

Methods

universe :: [Predicate a] #

(Finite a, Ord a) => Finite (Predicate a) Source #
>>> mapM_ print (universe :: [Predicate Ordering])
Predicate {getPredicate = [(LT,False),(EQ,False),(GT,False)]}
Predicate {getPredicate = [(LT,True),(EQ,False),(GT,False)]}
Predicate {getPredicate = [(LT,False),(EQ,True),(GT,False)]}
Predicate {getPredicate = [(LT,True),(EQ,True),(GT,False)]}
Predicate {getPredicate = [(LT,False),(EQ,False),(GT,True)]}
Predicate {getPredicate = [(LT,True),(EQ,False),(GT,True)]}
Predicate {getPredicate = [(LT,False),(EQ,True),(GT,True)]}
Predicate {getPredicate = [(LT,True),(EQ,True),(GT,True)]}

Beware, function type universes are large...

>>> cardinality :: Tagged (Predicate Int8) Natural
Tagged 115792089237316195423570985008687907853269984665640564039457584007913129639936

... but thanks to laziness, you can expect at least few:

>>> let Predicate f : _ = universe :: [Predicate Int8]
>>> f 0
False
Instance details

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

Methods

universe :: [Op a b] #

(Representable f, Finite (Rep f), Ord (Rep f), Universe a) => Universe (Co f a) Source #

We could do this:

instance Universe (f a) => Universe (Co f a) where universe = map Rep universe

However, since you probably only apply Rep to functors when you want to think of them as being representable, I think it makes sense to use an instance based on the representable-ness rather than the inherent universe-ness.

Please complain if you disagree!

Instance details

Methods

universe :: [Co f a] #

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

Methods

universeF :: [Op a b] #

cardinality :: Tagged (Op a b) Natural #

(Representable f, Finite (Rep f), Ord (Rep f), Finite a) => Finite (Co f a) Source # 
Instance details

Methods

universeF :: [Co f a] #

cardinality :: Tagged (Co f a) Natural #

(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Universe a) => Universe (TracedT s f a) Source # 
Instance details

Methods

universe :: [TracedT s f a] #

(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Finite a) => Finite (TracedT s f a) Source # 
Instance details

Methods

universeF :: [TracedT s f a] #

cardinality :: Tagged (TracedT s f a) Natural #