ImperativeHaskell-0.2.0.1: A library for writing Imperative style haskell.

PortabilityGADTs, EmptyDataDecls, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances
Stabilityexperimental
MaintainerMatthew Mirman <mmirman@andrew.cmu.edu>
Safe HaskellNone

Control.Monad.Imperative.ImperativeMonad

Description

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

Synopsis

Documentation

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

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

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

for(init, check, incr) acts like the usual imperative for loop

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

while(check) acts like the usual imperative while

break' :: MIO a ()Source

break exists the current loop.

continue' :: MIO a ()Source

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

return' :: Returnable b r => V a b b -> MIO b rSource

return' 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.

returnV :: V a b b -> MIO b ()Source

returnV value 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.

returnF :: V a b b -> MIO b bSource

returnF value 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 inside of loops. Inside of loops, we need returnV

function :: MIO a a -> MIO b aSource

function foo takes an ImperativeMonad action and removes it from it's specific function context, specifically making it applicable in the body of other functions.

new :: a -> MIO r (V Var r a)Source

new constructs a new reference object with the value specified

auto :: aSource

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

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

liftOp2 :: (t -> t1 -> a) -> V b r t -> V b1 r t1 -> V Comp r aSource

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

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

data V b r a whereSource

Constructors

Lit :: a -> V Val r a 

Instances

Assignable (V b) 

(=:) :: Assignable val => V Var r a -> val r a -> MIO r ()Source

var =: value simply rewrites whatever is in var with whatever value is.

(&) :: V Var r a -> V Var s aSource

(&)a gets a reference/pointer to the variable specified