Some common types used by the species library.
- newtype LazyRing a = LR {
- unLR :: a
- type LazyQ = LazyRing Rational
- type LazyZ = LazyRing Integer
- newtype EGF = EGF (T LazyQ)
- egfFromCoeffs :: [LazyQ] -> EGF
- liftEGF :: (T LazyQ -> T LazyQ) -> EGF -> EGF
- liftEGF2 :: (T LazyQ -> T LazyQ -> T LazyQ) -> EGF -> EGF -> EGF
- newtype GF = GF (T Integer)
- gfFromCoeffs :: [Integer] -> GF
- liftGF :: (T Integer -> T Integer) -> GF -> GF
- liftGF2 :: (T Integer -> T Integer -> T Integer) -> GF -> GF -> GF
- newtype CycleIndex = CI (T Rational)
- ciFromMonomials :: [T Rational] -> CycleIndex
- liftCI :: (T Rational -> T Rational) -> CycleIndex -> CycleIndex
- liftCI2 :: (T Rational -> T Rational -> T Rational) -> CycleIndex -> CycleIndex -> CycleIndex
- filterCoeffs :: C a => (Integer -> Bool) -> [a] -> [a]
- selectIndex :: (C a, Eq a) => Integer -> [a] -> [a]
- class Functor f => ShowF f where
- newtype RawString = RawString String
- newtype Const x a = Const x
- newtype Identity a = Identity a
- newtype Sum f g a = Sum {}
- newtype Prod f g a = Prod {
- unProd :: (f a, g a)
- data Comp f g a = Comp {
- unComp :: f (g a)
- newtype Cycle a = Cycle [a]
- data Star a
- data Z
- data S n
- data X
- data f :+: g
- data f :*: g
- data f :.: g
- data Der f
- data E
- data C
- data NonEmpty f
- type family StructureF t :: * -> *
Lazy multiplication
If T
is an instance of Ring
, then LazyRing T
is isomorphic
to T but with a lazy multiplication: 0 * undefined = undefined * 0
= 0
.
Series types
Exponential generating functions, for counting labelled species.
egfFromCoeffs :: [LazyQ] -> EGFSource
Ordinary generating functions, for counting unlabelled species.
gfFromCoeffs :: [Integer] -> GFSource
newtype CycleIndex Source
Cycle index series.
ciFromMonomials :: [T Rational] -> CycleIndexSource
liftCI :: (T Rational -> T Rational) -> CycleIndex -> CycleIndexSource
liftCI2 :: (T Rational -> T Rational -> T Rational) -> CycleIndex -> CycleIndex -> CycleIndexSource
filterCoeffs :: C a => (Integer -> Bool) -> [a] -> [a]Source
Filter the coefficients of a series according to a predicate.
selectIndex :: (C a, Eq a) => Integer -> [a] -> [a]Source
Set every coefficient of a series to 0 except the selected index. Truncate any trailing zeroes.
Higher-order Show
class Functor f => ShowF f whereSource
When generating species, we build up a functor representing structures of that species; in order to display generated structures, we need to know that applying the computed functor to a Showable type will also yield something Showable.
Structure functors
Functors used in building up structures for species generation.
The constant functor.
Const x |
The identity functor.
Identity a |
Functor coproduct.
Functor product.
Functor composition.
Cycle structure. A value of type 'Cycle a' is implemented as '[a]', but thought of as a directed cycle.
Cycle [a] |
Type-level species
Some constructor-less data types used as indices to SpeciesAlgT
to reflect the species structure at the type level. This is the
point at which we wish we were doing this in a dependently typed
language.
type family StructureF t :: * -> *Source
StructureF
is a type function which maps type-level species
descriptions to structure functors. That is, a structure of the
species with type-level representation s
, on the underlying set
a
, has type StructureF s a
.