-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for writing Imperative style haskell. -- -- A monad that uses GADTs and continuations to replicate what it is like -- to program in an imperative language like C or Java with -- return, for, break, continue, and mutable -- references. @package ImperativeHaskell @version 0.2.0.1 -- | A module which defines the monad for ImperativeHaskell, and some -- control operator to interact with MIO module Control.Monad.Imperative.ImperativeMonad -- | modifyOp f makes a modify operator out of a binary -- haskell function modifyOp :: (a -> b -> a) -> V Var r a -> V k r b -> MIO r () -- | 'if'(check) m only executes m if the check is true. it is -- specifically value in it's argument. if' :: V b r Bool -> MIO r () -> MIO r () -- | for(init, check, incr) acts like the usual -- imperative for loop for' :: (MIO r irr1, V b r Bool, MIO r irr2) -> MIO r () -> MIO r () -- | while(check) acts like the usual imperative while while' :: V b r Bool -> MIO r () -> MIO r () -- | break exists the current loop. break' :: MIO a () -- | continue continues the current loop, passing over -- any control flow that is defined. continue' :: MIO a () -- | 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. return' :: Returnable b r => V a b b -> MIO b r -- | 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. returnV :: V a b b -> MIO b () -- | 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 returnF :: V a b b -> MIO b b -- | 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. function :: MIO a a -> MIO b a -- | new constructs a new reference object with the value -- specified new :: a -> MIO r (V Var r a) -- | auto should just be used where the type can be automatically -- infered and we don't need an initial value auto :: a runImperative :: MIO a a -> IO a -- | liftOp f turns a pure function into one which gets the -- values out of it's arguments 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 Lit :: a -> V Val r a -- | var =: value simply rewrites whatever is in -- var with whatever value is. (=:) :: Assignable val => V Var r a -> val r a -> MIO r () -- | (&)a gets a reference/pointer to the variable -- specified (&) :: V Var r a -> V Var s a instance Monad (MIO r) instance MonadCont (MIO r) instance Assignable MIO instance Assignable (V b) instance Returnable b b instance Returnable b () -- | Some predefined operators for the imperative monad. module Control.Monad.Imperative.ImperativeOperators (+=:) :: Num b => V Var r b -> V k r b -> MIO r () (*=:) :: Num b => V Var r b -> V k r b -> MIO r () (-=:) :: Num b => V Var r b -> V k r b -> MIO r () (%=:) :: Integral b => V Var r b -> V k r b -> MIO r () (<.) :: Ord t1 => V b r t1 -> V b1 r t1 -> V Comp r Bool (>.) :: Ord t1 => V b r t1 -> V b1 r t1 -> V Comp r Bool (+.) :: Num a => V b r a -> V b1 r a -> V Comp r a (*.) :: Num a => V b r a -> V b1 r a -> V Comp r a -- | A front end for the ImperativeMonad module Control.Monad.Imperative