universe-instances-extended-1.1: Universe instances for types from selected extra packages

Safe HaskellSafe
LanguageHaskell2010

Data.Universe.Instances.Extended

Contents

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

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

Defined in Data.Universe.Class

Methods

universe :: [Set a] #

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

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

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

(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 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
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 => 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) 
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 #

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

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

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