Safe Haskell | None |
---|---|
Language | Haskell2010 |
Stack zipping.
This module provides functions for flattening stacks into tuples.
Also here we define an instance which turns any instruction, not only lambdas, into a valid value.
Synopsis
- class ZipInstr (s :: [Type]) where
- type ZippedStack s :: Type
- zipInstr :: s :-> '[ZippedStack s]
- unzipInstr :: '[ZippedStack s] :-> s
- type ZipInstrs ss = Each '[ZipInstr] ss
- zippingStack :: ZipInstrs [inp, out] => (inp :-> out) -> Lambda (ZippedStack inp) (ZippedStack out)
- unzippingStack :: ZipInstrs [inp, out] => Lambda (ZippedStack inp) (ZippedStack out) -> inp :-> out
Documentation
class ZipInstr (s :: [Type]) where Source #
Zipping stack into tuple and back.
type ZippedStack s :: Type Source #
A type which contains the whole stack zipped.
zipInstr :: s :-> '[ZippedStack s] Source #
Fold given stack into single value.
unzipInstr :: '[ZippedStack s] :-> s Source #
Unfold given stack from a single value.
Instances
ZipInstr ([] :: [Type]) Source # | |
Defined in Lorentz.Zip type ZippedStack [] :: Type Source # zipInstr :: [] :-> (ZippedStack [] ': []) Source # unzipInstr :: (ZippedStack [] ': []) :-> [] Source # | |
ZipInstr (a ': ([] :: [Type])) Source # | |
Defined in Lorentz.Zip type ZippedStack (a ': []) :: Type Source # zipInstr :: (a ': []) :-> (ZippedStack (a ': []) ': []) Source # unzipInstr :: (ZippedStack (a ': []) ': []) :-> (a ': []) Source # | |
ZipInstr ((a, b) ': s) => ZipInstr (a ': (b ': s)) Source # | Such definition seems the only possible one we can support efficiently. |
Defined in Lorentz.Zip type ZippedStack (a ': (b ': s)) :: Type Source # zipInstr :: (a ': (b ': s)) :-> (ZippedStack (a ': (b ': s)) ': []) Source # unzipInstr :: (ZippedStack (a ': (b ': s)) ': []) :-> (a ': (b ': s)) Source # |
type ZipInstrs ss = Each '[ZipInstr] ss Source #
Require several stacks to comply ZipInstr
constraint.
zippingStack :: ZipInstrs [inp, out] => (inp :-> out) -> Lambda (ZippedStack inp) (ZippedStack out) Source #
Flatten both ends of instruction stack.
unzippingStack :: ZipInstrs [inp, out] => Lambda (ZippedStack inp) (ZippedStack out) -> inp :-> out Source #
Unflatten both ends of instruction stack.