| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Indigo.Internal.SIS
Synopsis
- newtype SomeIndigoState inp a = SomeIndigoState {
- unSIS :: MetaData inp -> SomeGenCode inp a
- data SomeGenCode inp a where
- SomeGenCode :: GenCode inp out a -> SomeGenCode inp a
- returnSIS :: a -> SomeIndigoState inp a
- bindSIS :: SomeIndigoState inp a -> (forall someOut. a -> SomeIndigoState someOut b) -> SomeIndigoState inp b
- toSIS :: IndigoState inp out a -> SomeIndigoState inp a
- runSIS :: SomeIndigoState inp a -> MetaData inp -> (forall out. GenCode inp out a -> r) -> r
- withSIS :: SomeIndigoState inp a -> (forall out. IndigoState inp out a -> SomeIndigoState inp b) -> SomeIndigoState inp b
- withSIS1 :: KnownValue x => (Var x -> SomeIndigoState (x & inp) a) -> (forall out. (Var x -> IndigoState (x & inp) out a) -> SomeIndigoState inp b) -> SomeIndigoState inp b
- withSIS2 :: (KnownValue x, KnownValue y) => (Var x -> Var y -> SomeIndigoState (x & (y & inp)) a) -> (forall out. (Var x -> Var y -> IndigoState (x & (y & inp)) out a) -> SomeIndigoState inp b) -> SomeIndigoState inp b
Documentation
newtype SomeIndigoState inp a Source #
IndigoState with hidden output stack,
necessary to generate typed Lorentz code from untyped Indigo frontend.
Constructors
| SomeIndigoState | |
Fields
| |
Instances
| Functor (SomeIndigoState inp) Source # | |
Defined in Indigo.Internal.SIS Methods fmap :: (a -> b) -> SomeIndigoState inp a -> SomeIndigoState inp b # (<$) :: a -> SomeIndigoState inp b -> SomeIndigoState inp a # | |
data SomeGenCode inp a where Source #
Gen code with hidden output stack
Constructors
| SomeGenCode :: GenCode inp out a -> SomeGenCode inp a |
Instances
| Functor (SomeGenCode inp) Source # | |
Defined in Indigo.Internal.SIS Methods fmap :: (a -> b) -> SomeGenCode inp a -> SomeGenCode inp b # (<$) :: a -> SomeGenCode inp b -> SomeGenCode inp a # | |
returnSIS :: a -> SomeIndigoState inp a Source #
bindSIS :: SomeIndigoState inp a -> (forall someOut. a -> SomeIndigoState someOut b) -> SomeIndigoState inp b Source #
Like bind, but the input type of the second parameter is determined by the output of the first one.
toSIS :: IndigoState inp out a -> SomeIndigoState inp a Source #
Convert IndigoState to SomeIndigoState
runSIS :: SomeIndigoState inp a -> MetaData inp -> (forall out. GenCode inp out a -> r) -> r Source #
To run SomeIndigoState you need to pass an handler of GenCode with any output stack.
withSIS :: SomeIndigoState inp a -> (forall out. IndigoState inp out a -> SomeIndigoState inp b) -> SomeIndigoState inp b Source #
Call an action with IndigoState stored in SomeIndigoState.
This function is kinda dummy because it passes
IndigoState to the function which produces a GenCode independently
on passed MetaData to it. It has to be used with only functions
which pass MetaData in the same way.
This function is needed to pass SomeIndigoState in contravariant positions
of statements like if, case, while, forEach, etc.
Alternative solution would be abstracting out IndigoState and SomeIndigoState
with typeclass
class CodeGenerator m where
runCodeGen :: m inp a -> MetaData inp -> (forall out . GenCode inp out a -> r) -> r
and passing CodeGenerator m in contravariant positions instead of IndigoState.
withSIS1 :: KnownValue x => (Var x -> SomeIndigoState (x & inp) a) -> (forall out. (Var x -> IndigoState (x & inp) out a) -> SomeIndigoState inp b) -> SomeIndigoState inp b Source #
The same as withSIS but converting a function with one argument, also dummy.
withSIS2 :: (KnownValue x, KnownValue y) => (Var x -> Var y -> SomeIndigoState (x & (y & inp)) a) -> (forall out. (Var x -> Var y -> IndigoState (x & (y & inp)) out a) -> SomeIndigoState inp b) -> SomeIndigoState inp b Source #
The same as withSIS1 but converting a function with 2 arguments, also dummy.