universe-base-1.1.4: A class for finite and recursively enumerable types.

Safe Haskell | Safe
Language | Haskell2010

Data.Universe.Helpers

Contents

- Building lists
- Building cardinalities
- Debugging

Synopsis

- universeDef :: (Bounded a, Enum a) => [a]
- interleave :: [[a]] -> [a]
- diagonal :: [[a]] -> [a]
- diagonals :: [[a]] -> [[a]]
- (+++) :: [a] -> [a] -> [a]
- cartesianProduct :: (a -> b -> c) -> [a] -> [b] -> [c]
- (+*+) :: [a] -> [b] -> [(a, b)]
- (<+*+>) :: [a -> b] -> [a] -> [b]
- choices :: [[a]] -> [[a]]
- retagWith :: (a -> b) -> Tagged a x -> Tagged b x
- retag :: forall {k1} {k2} (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
- newtype Tagged (s :: k) b = Tagged {
  - unTagged :: b
  }
- data Natural
- unfairCartesianProduct :: (a -> b -> c) -> [a] -> [b] -> [c]
- unfairChoices :: [[a]] -> [[a]]

# Documentation

This module is for functions that are useful for writing instances, but not necessarily for using them (and hence are not exported by the main module to avoid cluttering up the namespace).

# Building lists

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

For many types, the `universe` should be `[minBound .. maxBound]`; `universeDef` makes it easy to make such types an instance of `Universe` via the snippet

    instance Universe Foo where universe = universeDef

interleave :: [[a]] -> [a] Source #

Fair n-way interleaving: given a finite number of (possibly infinite) lists, produce a single list such that whenever `v` has finite index in one of the input lists, `v` also has finite index in the output list. No list's elements occur more frequently (on average) than another's.

diagonal :: [[a]] -> [a] Source #

Unfair n-way interleaving: given a possibly infinite number of (possibly infinite) lists, produce a single list such that whenever `v` has finite index in an input list at finite index, `v` also has finite index in the output list. Elements from lists at lower index occur more frequently, but not exponentially so.

diagonals :: [[a]] -> [[a]] Source #

Like `diagonal`, but expose a tiny bit more (non-semantic) information: if you lay out the input list in two dimensions, each list in the result will be one of the diagonals of the input. In particular, each element of the output will be a list whose elements are each from a distinct input list.

(+++) :: [a] -> [a] -> [a] Source #

Fair 2-way interleaving.

cartesianProduct :: (a -> b -> c) -> [a] -> [b] -> [c] Source #

Slightly unfair 2-way Cartesian product: given two (possibly infinite) lists, produce a single list such that whenever `v` and `w` have finite indices in the input lists, `(v,w)` has finite index in the output list. Lower indices occur as the `fst` part of the tuple more frequently, but not exponentially so.

(+*+) :: [a] -> [b] -> [(a, b)] Source #

    cartesianProduct (,)

(<+*+>) :: [a -> b] -> [a] -> [b] Source #

A `+*+` with application.

    cartesianProduct ($)

choices :: [[a]] -> [[a]] Source #

Slightly unfair n-way Cartesian product: given a finite number of (possibly infinite) lists, produce a single list such that whenever `vi` has finite index in list i for each i, `[v1, ..., vn]` has finite index in the output list.

# Building cardinalities

These functions are handy for inheriting the definition of `cardinality` in a newtype instance. For example, one might write

    newtype Foo = Foo Bar
    instance Finite Foo where cardinality = retagWith Foo cardinality

retagWith :: (a -> b) -> Tagged a x -> Tagged b x Source #

retag :: forall {k1} {k2} (s :: k1) b (t :: k2). Tagged s b -> Tagged t b Source #

Some times you need to change the tag you have lying around. Idiomatic usage is to make a new combinator for the relationship between the tags that you want to enforce, and define that combinator using `retag`.

    data Succ n
    retagSucc :: Tagged n a -> Tagged (Succ n) a
    retagSucc = retag

newtype Tagged (s :: k) b Source #

A ``Tagged` s b` value is a value `b` with an attached phantom type `s`. This can be used in place of the more traditional but less safe idiom of passing in an undefined value with the type, because unlike an `(s -> b)`, a ``Tagged` s b` can't try to use the argument `s` as a real value.

Moreover, you don't have to rely on the compiler to inline away the extra argument, because the newtype is "free"

`Tagged` has kind `k -> * -> *` if the compiler supports `PolyKinds`, therefore there is an extra `k` showing in the instance haddocks that may cause confusion.

Constructors

Tagged |

Fields

- unTagged :: b

#### Instances

Instances details

Generic1 (Tagged s :: Type -> Type) |

Instance details

Defined in Data.Tagged

Associated Types

type Rep1 (Tagged s :: Type -> Type) |
Instance details Defined in Data.Tagged type Rep1 (Tagged s :: Type -> Type) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

Methods

from1 :: Tagged s a -> Rep1 (Tagged s) a Source #

to1 :: Rep1 (Tagged s) a -> Tagged s a Source #

Bifoldable (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bifold :: Monoid m => Tagged m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged a b -> c Source #
Bifoldable1 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bifold1 :: Semigroup m => Tagged m m -> m Source # bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> Tagged a b -> m Source #
Bifunctor (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bimap :: (a -> b) -> (c -> d) -> Tagged a c -> Tagged b d Source # first :: (a -> b) -> Tagged a c -> Tagged b c Source # second :: (b -> c) -> Tagged a b -> Tagged a c Source #
Bitraversable (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Tagged a b -> f (Tagged c d) Source #
Eq2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged a c -> Tagged b d -> Bool Source #
Ord2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged a c -> Tagged b d -> Ordering Source #
Read2 (Tagged :: Type -> Type -> Type) |

Instance details

Defined in Data.Tagged

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Tagged a b) Source #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Tagged a b] Source #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Tagged a b) Source #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Tagged a b] Source #

Show2 (Tagged :: Type -> Type -> Type) |
Instance details Defined in Data.Tagged Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Tagged a b -> ShowS Source # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Tagged a b] -> ShowS Source #
Foldable1 (Tagged a) |

Instance details

Defined in Data.Tagged

Methods

fold1 :: Semigroup m => Tagged a m -> m Source #

foldMap1 :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m Source #

foldMap1' :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m Source #

toNonEmpty :: Tagged a a0 -> NonEmpty a0 Source #

maximum :: Ord a0 => Tagged a a0 -> a0 Source #

minimum :: Ord a0 => Tagged a a0 -> a0 Source #

head :: Tagged a a0 -> a0 Source #

last :: Tagged a a0 -> a0 Source #

foldrMap1 :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b Source #

foldlMap1' :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b Source #

foldlMap1 :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b Source #

foldrMap1' :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b Source #

Eq1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool Source #
Ord1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering Source #
Read1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged s a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged s a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Tagged s a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Tagged s a] Source #
Show1 (Tagged s) |
Instance details Defined in Data.Tagged Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS Source #
Applicative (Tagged s) |
Instance details Defined in Data.Tagged Methods pure :: a -> Tagged s a Source # (<*>) :: Tagged s (a -> b) -> Tagged s a -> Tagged s b Source # liftA2 :: (a -> b -> c) -> Tagged s a -> Tagged s b -> Tagged s c Source # (*>) :: Tagged s a -> Tagged s b -> Tagged s b Source # (<*) :: Tagged s a -> Tagged s b -> Tagged s a Source #
Functor (Tagged s) |
Instance details Defined in Data.Tagged Methods fmap :: (a -> b) -> Tagged s a -> Tagged s b Source # (<$) :: a -> Tagged s b -> Tagged s a Source #
Monad (Tagged s) |
Instance details Defined in Data.Tagged Methods (>>=) :: Tagged s a -> (a -> Tagged s b) -> Tagged s b Source # (>>) :: Tagged s a -> Tagged s b -> Tagged s b Source # return :: a -> Tagged s a Source #
Foldable (Tagged s) |

Instance details

Defined in Data.Tagged

Methods

fold :: Monoid m => Tagged s m -> m Source #

foldMap :: Monoid m => (a -> m) -> Tagged s a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Tagged s a -> m Source #

foldr :: (a -> b -> b) -> b -> Tagged s a -> b Source #

foldr' :: (a -> b -> b) -> b -> Tagged s a -> b Source #

foldl :: (b -> a -> b) -> b -> Tagged s a -> b Source #

foldl' :: (b -> a -> b) -> b -> Tagged s a -> b Source #

foldr1 :: (a -> a -> a) -> Tagged s a -> a Source #

foldl1 :: (a -> a -> a) -> Tagged s a -> a Source #

toList :: Tagged s a -> [a] Source #

null :: Tagged s a -> Bool Source #

length :: Tagged s a -> Int Source #

elem :: Eq a => a -> Tagged s a -> Bool Source #

maximum :: Ord a => Tagged s a -> a Source #

minimum :: Ord a => Tagged s a -> a Source #

sum :: Num a => Tagged s a -> a Source #

product :: Num a => Tagged s a -> a Source #

Traversable (Tagged s) |
Instance details Defined in Data.Tagged Methods traverse :: Applicative f => (a -> f b) -> Tagged s a -> f (Tagged s b) Source # sequenceA :: Applicative f => Tagged s (f a) -> f (Tagged s a) Source # mapM :: Monad m => (a -> m b) -> Tagged s a -> m (Tagged s b) Source # sequence :: Monad m => Tagged s (m a) -> m (Tagged s a) Source #
NFData b => NFData (Tagged s b) |
Instance details Defined in Data.Tagged Methods rnf :: Tagged s b -> () Source #
(Semigroup a, Monoid a) => Monoid (Tagged s a) |
Instance details Defined in Data.Tagged Methods mempty :: Tagged s a Source # mappend :: Tagged s a -> Tagged s a -> Tagged s a Source # mconcat :: [Tagged s a] -> Tagged s a Source #
Semigroup a => Semigroup (Tagged s a) |
Instance details Defined in Data.Tagged Methods (<>) :: Tagged s a -> Tagged s a -> Tagged s a Source # sconcat :: NonEmpty (Tagged s a) -> Tagged s a Source # stimes :: Integral b => b -> Tagged s a -> Tagged s a Source #
Bits a => Bits (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

(.&.) :: Tagged s a -> Tagged s a -> Tagged s a Source #

(.|.) :: Tagged s a -> Tagged s a -> Tagged s a Source #

xor :: Tagged s a -> Tagged s a -> Tagged s a Source #

complement :: Tagged s a -> Tagged s a Source #

shift :: Tagged s a -> Int -> Tagged s a Source #

rotate :: Tagged s a -> Int -> Tagged s a Source #

zeroBits :: Tagged s a Source #

bit :: Int -> Tagged s a Source #

setBit :: Tagged s a -> Int -> Tagged s a Source #

clearBit :: Tagged s a -> Int -> Tagged s a Source #

complementBit :: Tagged s a -> Int -> Tagged s a Source #

testBit :: Tagged s a -> Int -> Bool Source #

bitSizeMaybe :: Tagged s a -> Maybe Int Source #

bitSize :: Tagged s a -> Int Source #

isSigned :: Tagged s a -> Bool Source #

shiftL :: Tagged s a -> Int -> Tagged s a Source #

unsafeShiftL :: Tagged s a -> Int -> Tagged s a Source #

shiftR :: Tagged s a -> Int -> Tagged s a Source #

unsafeShiftR :: Tagged s a -> Int -> Tagged s a Source #

rotateL :: Tagged s a -> Int -> Tagged s a Source #

rotateR :: Tagged s a -> Int -> Tagged s a Source #

popCount :: Tagged s a -> Int Source #

FiniteBits a => FiniteBits (Tagged s a) |
Instance details Defined in Data.Tagged Methods finiteBitSize :: Tagged s a -> Int Source # countLeadingZeros :: Tagged s a -> Int Source # countTrailingZeros :: Tagged s a -> Int Source #
(Data s, Data b) => Data (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Tagged s b -> c (Tagged s b) Source #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tagged s b) Source #

toConstr :: Tagged s b -> Constr Source #

dataTypeOf :: Tagged s b -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tagged s b)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tagged s b)) Source #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tagged s b -> Tagged s b Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Tagged s b -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged s b -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) Source #

IsString a => IsString (Tagged s a) |
Instance details Defined in Data.Tagged Methods fromString :: String -> Tagged s a Source #
Bounded b => Bounded (Tagged s b) |
Instance details Defined in Data.Tagged Methods minBound :: Tagged s b Source # maxBound :: Tagged s b Source #
Enum a => Enum (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

succ :: Tagged s a -> Tagged s a Source #

pred :: Tagged s a -> Tagged s a Source #

toEnum :: Int -> Tagged s a Source #

fromEnum :: Tagged s a -> Int Source #

enumFrom :: Tagged s a -> [Tagged s a] Source #

enumFromThen :: Tagged s a -> Tagged s a -> [Tagged s a] Source #

enumFromTo :: Tagged s a -> Tagged s a -> [Tagged s a] Source #

enumFromThenTo :: Tagged s a -> Tagged s a -> Tagged s a -> [Tagged s a] Source #

Floating a => Floating (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

pi :: Tagged s a Source #

exp :: Tagged s a -> Tagged s a Source #

log :: Tagged s a -> Tagged s a Source #

sqrt :: Tagged s a -> Tagged s a Source #

(**) :: Tagged s a -> Tagged s a -> Tagged s a Source #

logBase :: Tagged s a -> Tagged s a -> Tagged s a Source #

sin :: Tagged s a -> Tagged s a Source #

cos :: Tagged s a -> Tagged s a Source #

tan :: Tagged s a -> Tagged s a Source #

asin :: Tagged s a -> Tagged s a Source #

acos :: Tagged s a -> Tagged s a Source #

atan :: Tagged s a -> Tagged s a Source #

sinh :: Tagged s a -> Tagged s a Source #

cosh :: Tagged s a -> Tagged s a Source #

tanh :: Tagged s a -> Tagged s a Source #

asinh :: Tagged s a -> Tagged s a Source #

acosh :: Tagged s a -> Tagged s a Source #

atanh :: Tagged s a -> Tagged s a Source #

log1p :: Tagged s a -> Tagged s a Source #

expm1 :: Tagged s a -> Tagged s a Source #

log1pexp :: Tagged s a -> Tagged s a Source #

log1mexp :: Tagged s a -> Tagged s a Source #

RealFloat a => RealFloat (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

floatRadix :: Tagged s a -> Integer Source #

floatDigits :: Tagged s a -> Int Source #

floatRange :: Tagged s a -> (Int, Int) Source #

decodeFloat :: Tagged s a -> (Integer, Int) Source #

encodeFloat :: Integer -> Int -> Tagged s a Source #

exponent :: Tagged s a -> Int Source #

significand :: Tagged s a -> Tagged s a Source #

scaleFloat :: Int -> Tagged s a -> Tagged s a Source #

isNaN :: Tagged s a -> Bool Source #

isInfinite :: Tagged s a -> Bool Source #

isDenormalized :: Tagged s a -> Bool Source #

isNegativeZero :: Tagged s a -> Bool Source #

isIEEE :: Tagged s a -> Bool Source #

atan2 :: Tagged s a -> Tagged s a -> Tagged s a Source #

Storable a => Storable (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

sizeOf :: Tagged s a -> Int Source #

alignment :: Tagged s a -> Int Source #

peekElemOff :: Ptr (Tagged s a) -> Int -> IO (Tagged s a) Source #

pokeElemOff :: Ptr (Tagged s a) -> Int -> Tagged s a -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO (Tagged s a) Source #

pokeByteOff :: Ptr b -> Int -> Tagged s a -> IO () Source #

peek :: Ptr (Tagged s a) -> IO (Tagged s a) Source #

poke :: Ptr (Tagged s a) -> Tagged s a -> IO () Source #

Generic (Tagged s b) |

Instance details

Defined in Data.Tagged

Associated Types

type Rep (Tagged s b) |
Instance details Defined in Data.Tagged type Rep (Tagged s b) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))

Methods

from :: Tagged s b -> Rep (Tagged s b) x Source #

to :: Rep (Tagged s b) x -> Tagged s b Source #

Ix b => Ix (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

range :: (Tagged s b, Tagged s b) -> [Tagged s b] Source #

index :: (Tagged s b, Tagged s b) -> Tagged s b -> Int Source #

unsafeIndex :: (Tagged s b, Tagged s b) -> Tagged s b -> Int Source #

inRange :: (Tagged s b, Tagged s b) -> Tagged s b -> Bool Source #

rangeSize :: (Tagged s b, Tagged s b) -> Int Source #

unsafeRangeSize :: (Tagged s b, Tagged s b) -> Int Source #

Num a => Num (Tagged s a) |
Instance details Defined in Data.Tagged Methods (+) :: Tagged s a -> Tagged s a -> Tagged s a Source # (-) :: Tagged s a -> Tagged s a -> Tagged s a Source # (*) :: Tagged s a -> Tagged s a -> Tagged s a Source # negate :: Tagged s a -> Tagged s a Source # abs :: Tagged s a -> Tagged s a Source # signum :: Tagged s a -> Tagged s a Source # fromInteger :: Integer -> Tagged s a Source #
Read b => Read (Tagged s b) |
Instance details Defined in Data.Tagged Methods readsPrec :: Int -> ReadS (Tagged s b) Source # readList :: ReadS [Tagged s b] Source # readPrec :: ReadPrec (Tagged s b) Source # readListPrec :: ReadPrec [Tagged s b] Source #
Fractional a => Fractional (Tagged s a) |
Instance details Defined in Data.Tagged Methods (/) :: Tagged s a -> Tagged s a -> Tagged s a Source # recip :: Tagged s a -> Tagged s a Source # fromRational :: Rational -> Tagged s a Source #
Integral a => Integral (Tagged s a) |

Instance details

Defined in Data.Tagged

Methods

quot :: Tagged s a -> Tagged s a -> Tagged s a Source #

rem :: Tagged s a -> Tagged s a -> Tagged s a Source #

div :: Tagged s a -> Tagged s a -> Tagged s a Source #

mod :: Tagged s a -> Tagged s a -> Tagged s a Source #

quotRem :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) Source #

divMod :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) Source #

toInteger :: Tagged s a -> Integer Source #

Real a => Real (Tagged s a) |
Instance details Defined in Data.Tagged Methods toRational :: Tagged s a -> Rational Source #
RealFrac a => RealFrac (Tagged s a) |
Instance details Defined in Data.Tagged Methods properFraction :: Integral b => Tagged s a -> (b, Tagged s a) Source # truncate :: Integral b => Tagged s a -> b Source # round :: Integral b => Tagged s a -> b Source # ceiling :: Integral b => Tagged s a -> b Source # floor :: Integral b => Tagged s a -> b Source #
Show b => Show (Tagged s b) |
Instance details Defined in Data.Tagged Methods showsPrec :: Int -> Tagged s b -> ShowS Source # show :: Tagged s b -> String Source # showList :: [Tagged s b] -> ShowS Source #
Eq b => Eq (Tagged s b) |
Instance details Defined in Data.Tagged Methods (==) :: Tagged s b -> Tagged s b -> Bool Source # (/=) :: Tagged s b -> Tagged s b -> Bool Source #
Ord b => Ord (Tagged s b) |

Instance details

Defined in Data.Tagged

Methods

compare :: Tagged s b -> Tagged s b -> Ordering Source #

(<) :: Tagged s b -> Tagged s b -> Bool Source #

(<=) :: Tagged s b -> Tagged s b -> Bool Source #

(>) :: Tagged s b -> Tagged s b -> Bool Source #

(>=) :: Tagged s b -> Tagged s b -> Bool Source #

max :: Tagged s b -> Tagged s b -> Tagged s b Source #

min :: Tagged s b -> Tagged s b -> Tagged s b Source #

Finite a => Finite (Tagged b a) Source # |
Instance details Defined in Data.Universe.Class Methods universeF :: [Tagged b a] Source # cardinality :: Tagged (Tagged b a) Natural Source #
Universe a => Universe (Tagged b a) Source # |
Instance details Defined in Data.Universe.Class Methods universe :: [Tagged b a] Source #
type Rep1 (Tagged s :: Type -> Type) |
Instance details Defined in Data.Tagged type Rep1 (Tagged s :: Type -> Type) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Tagged s b) |
Instance details Defined in Data.Tagged type Rep (Tagged s b) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.9-EraSdp0lx7uJnqESyrqLTP" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))

data Natural Source #

Natural number

Invariant: numbers <= 0xffffffffffffffff use the `NS` constructor

#### Instances

Instances details

PrintfArg Natural | Since: base-4.8.0.0
Instance details Defined in Text.Printf Methods formatArg :: Natural -> FieldFormatter Source # parseFormat :: Natural -> ModifierParser Source #
NFData Natural | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Natural -> () Source #
Enum Natural | Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Enum

Methods

succ :: Natural -> Natural Source #

pred :: Natural -> Natural Source #

toEnum :: Int -> Natural Source #

fromEnum :: Natural -> Int Source #

enumFrom :: Natural -> [Natural] Source #

enumFromThen :: Natural -> Natural -> [Natural] Source #

enumFromTo :: Natural -> Natural -> [Natural] Source #

enumFromThenTo :: Natural -> Natural -> Natural -> [Natural] Source #

Num Natural | Note that `Natural`'s `Num` instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though. Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Num Methods (+) :: Natural -> Natural -> Natural Source # (-) :: Natural -> Natural -> Natural Source # (*) :: Natural -> Natural -> Natural Source # negate :: Natural -> Natural Source # abs :: Natural -> Natural Source # signum :: Natural -> Natural Source # fromInteger :: Integer -> Natural Source #
Integral Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Real Methods quot :: Natural -> Natural -> Natural Source # rem :: Natural -> Natural -> Natural Source # div :: Natural -> Natural -> Natural Source # mod :: Natural -> Natural -> Natural Source # quotRem :: Natural -> Natural -> (Natural, Natural) Source # divMod :: Natural -> Natural -> (Natural, Natural) Source # toInteger :: Natural -> Integer Source #
Real Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Internal.Real Methods toRational :: Natural -> Rational Source #
Eq Natural |
Instance details Defined in GHC.Num.Natural Methods (==) :: Natural -> Natural -> Bool Source # (/=) :: Natural -> Natural -> Bool Source #
Ord Natural |
Instance details Defined in GHC.Num.Natural Methods compare :: Natural -> Natural -> Ordering Source # (<) :: Natural -> Natural -> Bool Source # (<=) :: Natural -> Natural -> Bool Source # (>) :: Natural -> Natural -> Bool Source # (>=) :: Natural -> Natural -> Bool Source # max :: Natural -> Natural -> Natural Source # min :: Natural -> Natural -> Natural Source #
Universe Natural Source # |
Instance details Defined in Data.Universe.Class Methods universe :: [Natural] Source #
KnownNat n => HasResolution (n :: Nat) | For example, `Fixed 1000` will give you a `Fixed` with a resolution of 1000.
Instance details Defined in Data.Fixed Methods resolution :: p n -> Integer Source #
Lift Natural |
Instance details Defined in Language.Haskell.TH.Syntax Methods lift :: Quote m => Natural -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Natural -> Code m Natural Source #

# Debugging

These functions exist primarily as a specification to test against.

unfairCartesianProduct :: (a -> b -> c) -> [a] -> [b] -> [c] Source #

Very unfair 2-way Cartesian product: same guarantee as the slightly unfair one, except that lower indices may occur as the `fst` part of the tuple exponentially more frequently.

unfairChoices :: [[a]] -> [[a]] Source #

Very unfair n-way Cartesian product: same guarantee as the slightly unfair one, but not as good in the same sense that the very unfair 2-way product is worse than the slightly unfair 2-way product.