Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Documentation
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
xuniverse
-- any inhabitant has a finite index let pfx =take
nuniverse
-- any finite prefix of universe has unique elements inlength
pfx =length
(nub pfx)
Nothing
Instances
Universe Bool | |
Defined in Data.Universe.Class | |
Universe Char | |
Defined in Data.Universe.Class | |
Universe Int | |
Defined in Data.Universe.Class | |
Universe Int8 | |
Defined in Data.Universe.Class | |
Universe Int16 | |
Defined in Data.Universe.Class | |
Universe Int32 | |
Defined in Data.Universe.Class | |
Universe Int64 | |
Defined in Data.Universe.Class | |
Universe Integer | |
Defined in Data.Universe.Class | |
Universe Natural | |
Defined in Data.Universe.Class | |
Universe Ordering | |
Defined in Data.Universe.Class | |
Universe Word | |
Defined in Data.Universe.Class | |
Universe Word8 | |
Defined in Data.Universe.Class | |
Universe Word16 | |
Defined in Data.Universe.Class | |
Universe Word32 | |
Defined in Data.Universe.Class | |
Universe Word64 | |
Defined in Data.Universe.Class | |
Universe () | |
Defined in Data.Universe.Class | |
Universe Void | |
Defined in Data.Universe.Class | |
Universe All | |
Defined in Data.Universe.Class | |
Universe Any | |
Defined in Data.Universe.Class | |
Universe a => Universe [a] | |
Defined in Data.Universe.Class | |
Universe a => Universe (Maybe a) | |
Defined in Data.Universe.Class | |
RationalUniverse a => Universe (Ratio a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Solo a) | |
Defined in Data.Universe.Class | |
(Finite a, Ord a) => Universe (Predicate a) Source # | |
Defined in Data.Universe.Instances.Extended | |
Universe a => Universe (Min a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Max a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (First a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Last a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Identity a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (First a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Last a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Dual a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Sum a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Product a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (NonEmpty a) | |
Defined in Data.Universe.Class | |
(Ord a, Universe a) => Universe (Set a) |
|
Defined in Data.Universe.Class | |
(Finite a, Ord a, Universe b) => Universe (a -> b) |
|
Defined in Data.Universe.Class | |
(Universe a, Universe b) => Universe (Either a b) | |
Defined in Data.Universe.Class | |
(Universe a, Universe b) => Universe (a, b) | |
Defined in Data.Universe.Class | |
(Universe a, Finite b, Ord b) => Universe (Op a b) Source # | |
Defined in Data.Universe.Instances.Extended | |
(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! |
Defined in Data.Universe.Instances.Extended | |
Universe (Proxy a) | |
Defined in Data.Universe.Class | |
(Ord k, Finite k, Universe v) => Universe (Map k v) |
|
Defined in Data.Universe.Class | |
(Universe a, Universe b, Universe c) => Universe (a, b, c) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Const a b) | |
Defined in Data.Universe.Class | |
(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Universe a) => Universe (TracedT s f a) Source # | |
Defined in Data.Universe.Instances.Extended | |
Universe (f a) => Universe (IdentityT f a) | |
Defined in Data.Universe.Class | |
(Finite e, Ord e, Universe (m a)) => Universe (ReaderT e m a) | |
Defined in Data.Universe.Class | |
Universe a => Universe (Tagged b a) | |
Defined in Data.Universe.Class | |
(Universe a, Universe b, Universe c, Universe d) => Universe (a, b, c, d) | |
Defined in Data.Universe.Class | |
(Universe (f a), Universe (g a)) => Universe (Product f g a) | |
Defined in Data.Universe.Class | |
(Universe (f a), Universe (g a)) => Universe (Sum f g a) | |
Defined in Data.Universe.Class | |
(Universe a, Universe b, Universe c, Universe d, Universe e) => Universe (a, b, c, d, e) | |
Defined in Data.Universe.Class | |
Universe (f (g a)) => Universe (Compose f g a) | |
Defined in Data.Universe.Class |
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
xuniverseF
-- any inhabitant has a finite indexlength
(filter
(== x)universeF
) == 1 -- should terminate (xs ->cardinality
xs ==genericLength
xs)universeF
Note:
may not hold for all types, though the laws imply that elemIndex
x universe
== elemIndex
x universeF
universe
is a permutation of universeF
.
>>>
elemIndex (Left True :: Either Bool Bool) universe
Just 2
>>>
elemIndex (Left True :: Either Bool Bool) universeF
Just 1
Nothing
Instances
Finite Bool | |
Defined in Data.Universe.Class | |
Finite Char | |
Defined in Data.Universe.Class | |
Finite Int | |
Defined in Data.Universe.Class | |
Finite Int8 | |
Defined in Data.Universe.Class | |
Finite Int16 | |
Defined in Data.Universe.Class | |
Finite Int32 | |
Defined in Data.Universe.Class | |
Finite Int64 | |
Defined in Data.Universe.Class | |
Finite Ordering | |
Defined in Data.Universe.Class | |
Finite Word | |
Defined in Data.Universe.Class | |
Finite Word8 | |
Defined in Data.Universe.Class | |
Finite Word16 | |
Defined in Data.Universe.Class | |
Finite Word32 | |
Defined in Data.Universe.Class | |
Finite Word64 | |
Defined in Data.Universe.Class | |
Finite () | |
Defined in Data.Universe.Class | |
Finite Void | |
Defined in Data.Universe.Class | |
Finite All | |
Defined in Data.Universe.Class | |
Finite Any | |
Defined in Data.Universe.Class | |
Finite a => Finite (Maybe a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Solo a) | |
Defined in Data.Universe.Class | |
(Finite a, Ord a) => Finite (Predicate a) Source # |
Beware, function type universes are large...
... but thanks to laziness, you can expect at least few:
|
Defined in Data.Universe.Instances.Extended | |
Finite a => Finite (Min a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Max a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (First a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Last a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Identity a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (First a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Last a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Dual a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Sum a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Product a) | |
Defined in Data.Universe.Class | |
(Ord a, Finite a) => Finite (Set a) | |
Defined in Data.Universe.Class | |
(Ord a, Finite a, Finite b) => Finite (a -> b) |
|
Defined in Data.Universe.Class | |
(Finite a, Finite b) => Finite (Either a b) | |
Defined in Data.Universe.Class | |
(Finite a, Finite b) => Finite (a, b) | |
Defined in Data.Universe.Class | |
(Finite a, Finite b, Ord b) => Finite (Op a b) Source # | |
Defined in Data.Universe.Instances.Extended | |
(Representable f, Finite (Rep f), Ord (Rep f), Finite a) => Finite (Co f a) Source # | |
Defined in Data.Universe.Instances.Extended | |
Finite (Proxy a) | |
Defined in Data.Universe.Class | |
(Ord k, Finite k, Finite v) => Finite (Map k v) | |
Defined in Data.Universe.Class | |
(Finite a, Finite b, Finite c) => Finite (a, b, c) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Const a b) | |
Defined in Data.Universe.Class | |
(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Finite a) => Finite (TracedT s f a) Source # | |
Defined in Data.Universe.Instances.Extended | |
Finite (f a) => Finite (IdentityT f a) | |
Defined in Data.Universe.Class | |
(Finite e, Ord e, Finite (m a)) => Finite (ReaderT e m a) | |
Defined in Data.Universe.Class | |
Finite a => Finite (Tagged b a) | |
Defined in Data.Universe.Class | |
(Finite a, Finite b, Finite c, Finite d) => Finite (a, b, c, d) | |
Defined in Data.Universe.Class | |
(Finite (f a), Finite (g a)) => Finite (Product f g a) | |
Defined in Data.Universe.Class | |
(Finite (f a), Finite (g a)) => Finite (Sum f g a) | |
Defined in Data.Universe.Class | |
(Finite a, Finite b, Finite c, Finite d, Finite e) => Finite (a, b, c, d, e) | |
Defined in Data.Universe.Class | |
Finite (f (g a)) => Finite (Compose f g a) | |
Defined in Data.Universe.Class |
Orphan instances
(Finite a, Ord a) => Universe (Predicate a) Source # | |
(Finite a, Ord a) => Finite (Predicate a) Source # |
Beware, function type universes are large...
... but thanks to laziness, you can expect at least few:
|
(Universe a, Finite b, Ord b) => Universe (Op a b) Source # | |
(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! |
(Finite a, Finite b, Ord b) => Finite (Op a b) Source # | |
(Representable f, Finite (Rep f), Ord (Rep f), Finite a) => Finite (Co f a) Source # | |
(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Universe a) => Universe (TracedT s f a) Source # | |
(Representable f, Finite s, Ord s, Finite (Rep f), Ord (Rep f), Finite a) => Finite (TracedT s f a) Source # | |