Copyright | (c) 2018 Jiasen Wu |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jiasen Wu <jiasenwu@hotmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This module defins operations to manipulate the generic representation of tuple.
- data End a = End
- class Linearize (t :: * -> *) (b :: * -> *) where
- type family Length a :: Nat where ...
- length :: a x -> Proxy (Length a)
- type family Half (a :: Nat) :: Nat where ...
- half :: KnownNat n => Proxy n -> Proxy (Half n)
- data SNat
- type family ToSNat (a :: Nat) :: SNat where ...
- tosnat :: KnownNat n => Proxy n -> Proxy (ToSNat n)
- class Take (n :: SNat) (a :: * -> *) where
- class Drop (n :: SNat) (a :: * -> *) where
- class Normalize (a :: * -> *) where
- type MetaS = MetaSel Nothing NoSourceUnpackedness NoSourceStrictness DecidedLazy
- type family UnRec0 t where ...
- type family UnS1 t where ...
- type family UnD1 t where ...
Documentation
a sentinial datatype that represents a empty product
class Linearize (t :: * -> *) (b :: * -> *) where Source #
Representation of tuple are shaped in a balanced tree.
L
transforms the tree into a line, for further manipulation.
(Linearize v b, Linearize u (L v b)) => Linearize ((:*:) * u v) b Source # | inductive case. preppend a product with what ever |
Linearize (S1 * MetaS (Rec0 * t)) End Source # | base case 1. cons field with end |
Linearize (S1 * MetaS (Rec0 * t)) ((:*:) * b c) Source # | base case 3. cons field1 with a product |
Linearize (S1 * MetaS (Rec0 * t)) (S1 * MetaS (Rec0 * b)) Source # | base case 2. cons field1 with field2 |
type family Length a :: Nat where ... Source #
calculate the number of fields of a product note: undefined on non-product rep
Positive natural number in type level We rely on the SNat to define Take and Drop
class Normalize (a :: * -> *) where Source #
Normalize
converts a linear product back into a balanced tree.
(KnownNat ((+) (Length a) (Length b)), KnownNat (Half ((+) (Length a) (Length b))), Take (ToSNat (Half ((+) (Length a) (Length b)))) ((:*:) * a b), Drop (ToSNat (Half ((+) (Length a) (Length b)))) ((:*:) * a b), Normalize (T (ToSNat (Half ((+) (Length a) (Length b)))) ((:*:) * a b)), Normalize (D (ToSNat (Half ((+) (Length a) (Length b)))) ((:*:) * a b))) => Normalize ((:*:) * a b) Source # | inductive case. product |
Normalize (S1 * MetaS (Rec0 * t)) Source # | base case 1. singleton |