Portability | GADTs, EmptyDataDecls, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances |
---|---|
Stability | experimental |
Maintainer | Matthew Mirman <[email protected]> |
Safe Haskell | None |
Control.Monad.Imperative.Internals
Description
A module which defines the monad for ImperativeHaskell,
and some control operator to interact with MIO
- modifyOp :: ValTp k => (a -> b -> a) -> V Var r a -> V k r b -> MIO r ()
- if' :: ValTp b => V b r Bool -> MIO r () -> MIO r ()
- for' :: ValTp b => (MIO r irr1, V b r Bool, MIO r irr2) -> MIO r () -> MIO r ()
- while' :: ValTp b => V b r Bool -> MIO r () -> MIO r ()
- break' :: MIO a ()
- continue' :: MIO a ()
- return' :: (Returnable b r, ValTp a) => V a b b -> MIO b r
- returnV :: ValTp a => V a b b -> MIO b ()
- returnF :: ValTp a => V a b b -> MIO b b
- function :: MIO a a -> MIO b a
- new :: a -> MIO r (V Var r a)
- auto :: a
- runImperative :: MIO a a -> IO a
- data V b r a where
- class ValTp b
- data MIO r a
- data Comp
- data Val
- data Var
- (=:) :: Assignable valt => V Var r a -> valt r a -> MIO r ()
- (&) :: V Var r a -> V Var s a
- val :: ValTp b => V b r a -> MIO r a
Documentation
modifyOp :: ValTp k => (a -> b -> a) -> V Var r a -> V k r b -> MIO r ()Source
makes a modification assignment operator
out of a binary haskell function.
The suggested use is to replicate functionality of assignments
like modifyOp
-=
or %=
from C style languages.
if' :: ValTp b => V b r Bool -> MIO r () -> MIO r ()Source
only performs if'
(check) actact
if check
evaluates to true
it is specifically a value in its argument.
for' :: ValTp b => (MIO r irr1, V b r Bool, MIO r irr2) -> MIO r () -> MIO r ()Source
acts like its imperative for'
(init, check, incr)for
counterpart
while' :: ValTp b => V b r Bool -> MIO r () -> MIO r ()Source
acts like its imperative while'
(check)while
counterpart.
exists the current loop.
if called outside of a loop, rather than throwing a compilation error,
it will simply return a runtime error.
break'
continue'
continues the current loop, passing over
any control flow that is defined.
if called outside of a loop, rather than throwing a compilation error,
it will simply return a runtime error.
return' :: (Returnable b r, ValTp a) => V a b b -> MIO b rSource
can act as returnF or returnV depending on use
if it does not work, it is likely that type inference
could not figure out a sensible alternative.
return'
returnV :: ValTp a => V a b b -> MIO b ()Source
acts like the imperative return, where
if called, it will exit the current function and place the
returned value into the current continuation. Note, this
doesn't work as a last function call.
returnV
value
function :: MIO a a -> MIO b aSource
takes an ImperativeMonad action and removes it from it's
specific function context, specifically making it applicable
in the body of other functions.
function
foo
runImperative :: MIO a a -> IO aSource