Portability | GADTs, EmptyDataDecls, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances |
---|---|

Stability | experimental |

Maintainer | Matthew Mirman <mmirman@andrew.cmu.edu> |

Safe Haskell | None |

A module which defines the monad for ImperativeHaskell,
and some control operator to interact with `MIO`

- modifyOp :: (a -> b -> a) -> V Var r a -> V k r b -> MIO r ()
- if' :: V b r Bool -> MIO r () -> MIO r ()
- for' :: (MIO r irr1, V b r Bool, MIO r irr2) -> MIO r () -> MIO r ()
- while' :: V b r Bool -> MIO r () -> MIO r ()
- break' :: MIO a ()
- continue' :: MIO a ()
- return' :: Returnable b r => V a b b -> MIO b r
- returnV :: V a b b -> MIO b ()
- returnF :: 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
- liftOp :: (t -> a) -> V b r t -> V Comp r a
- liftOp2 :: (t -> t1 -> a) -> V b r t -> V b1 r t1 -> V Comp r a
- liftOp3 :: (t -> t1 -> t2 -> a) -> V b r t -> V b1 r t1 -> V b2 r t2 -> V Comp r a
- liftOp4 :: (t -> t1 -> t2 -> t3 -> a) -> V b r t -> V b1 r t1 -> V b2 r t2 -> V b3 r t3 -> V Comp r a
- liftOp5 :: (t -> t1 -> t2 -> t4 -> t3 -> a) -> V b r t -> V b1 r t1 -> V b2 r t2 -> V b3 r t3 -> V b4 r t4 -> V Comp r a
- data V b r a where
- (=:) :: Assignable val => V Var r a -> val r a -> MIO r ()
- (&) :: V Var r a -> V Var s a

# Documentation

modifyOp :: (a -> b -> a) -> V Var r a -> V k r b -> MIO r ()Source

makes a modify operator out of a binary
haskell function
`modifyOp`

f

if' :: V b r Bool -> MIO r () -> MIO r ()Source

`'if'(check) m`

only executes m if the check is true.
it is specifically value in it's argument.

for' :: (MIO r irr1, V b r Bool, MIO r irr2) -> MIO r () -> MIO r ()Source

acts like the usual imperative for loop
`for`

(init, check, incr)

continues the current loop, passing over
any control flow that is defined.
`continue`

return' :: Returnable b r => 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 :: 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

`auto`

should just be used where the
type can be automatically infered and we don't need an initial value

runImperative :: MIO a a -> IO aSource

liftOp :: (t -> a) -> V b r t -> V Comp r aSource

turns a pure function into one which
gets the values out of it's arguments
`liftOp`

f

liftOp4 :: (t -> t1 -> t2 -> t3 -> a) -> V b r t -> V b1 r t1 -> V b2 r t2 -> V b3 r t3 -> V Comp r aSource

liftOp5 :: (t -> t1 -> t2 -> t4 -> t3 -> a) -> V b r t -> V b1 r t1 -> V b2 r t2 -> V b3 r t3 -> V b4 r t4 -> V Comp r aSource