| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
NumHask.Shape
Contents
Description
numbers with a shape
- class HasShape f where
- type Shape f
- class Distributive f => Representable f where
- class Singleton f where
Documentation
class HasShape f where Source #
Not everything that has a shape is representable.
todo: Structure is a useful alternative concept/naming convention
Minimal complete definition
Representable
Representable has most of what's needed to define numbers that have elements (aka scalars) and a fixed shape.
class Distributive f => Representable f where #
A Functor f is Representable if tabulate and index witness an isomorphism to (->) x.
Every Distributive Functor is actually Representable.
Every Representable Functor from Hask to Hask is a right adjoint.
tabulate.index≡ idindex.tabulate≡ idtabulate.return≡return
Instances
| Representable Identity | |
| Representable Complex | |
| Representable Dual | |
| Representable Sum | |
| Representable Product | |
| Representable ((->) e) | |
| Representable f => Representable (Co f) | |
| Representable (Proxy *) | |
| Representable f => Representable (Cofree f) | |
| KnownNat n => Representable (Vector n) # | |
| Representable w => Representable (TracedT s w) | |
| Representable m => Representable (IdentityT * m) | |
| Representable (Tagged * t) | |
| (Representable f, Representable g) => Representable (Product * f g) | |
| Representable m => Representable (ReaderT * e m) | |
| (Representable f, Representable g) => Representable (Compose * * f g) | |
| (KnownNat m, KnownNat n) => Representable (Matrix Nat Nat m n) # | |
class Singleton f where Source #
This class could also be called replicate. Looking forward, however, it may be useful to consider a Representable such as
VectorThing a = Vector a | Single a | Zero
and then
singleton a = Single a singleton zero = Zero
short-circuiting an expensive computation. As the class action then doesn't actually involve replication, it would be mis-named.
Minimal complete definition
Instances
| Representable f => Singleton f Source # | |