Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated the .cabal

  • Loading branch information...
commit 08de62743d67be12406afe7ac5e0d1257545c739 1 parent a0dcc3a
@mmirman authored
View
30 Control/Monad/Imperative/Internals.hs
@@ -6,8 +6,7 @@
FlexibleContexts,
UndecidableInstances,
TypeFamilies,
- FunctionalDependencies,
- DataKinds
+ FunctionalDependencies
#-}
-----------------------------------------------------------------------------
@@ -36,8 +35,11 @@ module Control.Monad.Imperative.Internals
, io
, V(Lit, C)
, MIO()
- , ValueKind(..)
- , ControlKind(..)
+ , TyInLoop
+ , TyInFunc
+ , TyVar
+ , TyVal
+ , TyComp
, (=:)
, (&)
, HasValue(..)
@@ -50,12 +52,12 @@ import Control.Monad.State
import Data.IORef
import Data.String (IsString(..))
-data ControlKind = TyInLoop
- | TyInFunc
+data TyInLoop
+data TyInFunc
-data ValueKind = TyVar
- | TyVal
- | TyComp ControlKind ValueKind
+data TyVar
+data TyVal
+data TyComp i v
type RCont r = ContT r IO
type MIO_I i r a = StateT (Control i r) (RCont r) a
@@ -64,12 +66,12 @@ type RetCont r = r -> RCont r ()
newtype MIO i r a = MIO { getMIO :: MIO_I i r a }
deriving (Monad, MonadCont, MonadIO)
-data V (b :: ValueKind) r a where
+data V b r a where
R :: IORef a -> V TyVar r a
Lit :: a -> V TyVal r a
C :: MIO i r (V b r a) -> V (TyComp i b) r a
-data Control (i :: ControlKind) r where
+data Control i r where
InFunction :: RetCont r -> Control TyInFunc r
InLoop :: MIO TyInLoop r () -> MIO TyInLoop r () -> RetCont r -> Control i r
@@ -79,7 +81,7 @@ getReturn (InLoop _ _ ret) = ret
-- | Although the functional dependency @b -> i@ is declared,
-- it does not do anything useful.
-class HasValue r b (i :: ControlKind) | b -> r i where
+class HasValue r b i | b -> r i where
val :: b a -> MIO i r a
instance HasValue r (V TyVar r) i where
val (R r) = MIO $ liftIO $ readIORef r
@@ -93,7 +95,7 @@ instance HasValue r (MIO i r) i where
instance HasValue r IO i where
val m = liftIO m
-class CState (i :: ControlKind) where
+class CState i where
type RetTy i a
getState :: MIO i r (Control i r)
@@ -157,6 +159,8 @@ continue' = do
runWithRet :: MIO TyInFunc r a-> RetCont r -> RCont r a
runWithRet m r = fmap fst $ runStateT (getMIO m) $ InFunction r
+-- | 'defer'' executes the given action (or value) before the
+-- function returns.
defer' :: HasValue r valt TyInFunc => valt a -> MIO i r ()
defer' m = MIO $ do
c <- get
View
3  Control/Monad/Imperative/Operators.hs
@@ -1,6 +1,5 @@
{-# LANGUAGE
NoMonomorphismRestriction,
- DataKinds,
TypeFamilies,
FlexibleContexts
#-}
@@ -39,7 +38,7 @@ import Control.Monad.Imperative.Internals
(-.) a b = liftOp2 (-) a b
(*.) a b = liftOp2 (*) a b
-(%.) :: (Integral c, HasValue r (V b1 r) i, HasValue r (V b2 r) i) => V b1 r c -> V b2 r c -> V (TyComp i 'TyVal) r c
+(%.) :: (Integral c, HasValue r (V b1 r) i, HasValue r (V b2 r) i) => V b1 r c -> V b2 r c -> V (TyComp i TyVal) r c
(%.) a b = liftOp2 mod a b
(/.) :: (HasValue r (V b1 r) i, HasValue r (V b2 r) i, Fractional c) => V b1 r c -> V b2 r c -> V (TyComp i TyVal) r c
View
42 ImperativeHaskell.cabal
@@ -1,10 +1,28 @@
Name: ImperativeHaskell
-Version: 1.1.1.0
-Description: 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.
+Version: 2.0.0.0
+Description:
+ A monad that uses GADTs and continuations to replicate what it is like to program
+ in an imperative language like C, Java or Go with "return", "for", "break", "continue",
+ and mutable references.
+ .
+ In Version 2:
+ .
+ * Single return function: @return'@
+ .
+ * A Go language style @defer'@ primitive.
+ .
+ * Proper compiler errors when @break'@ and @continue'@ are used incorrectly
+ .
+ * /Note/: Version 2 has a very different internal structure from version 1,
+ and thus there will likely be type signature conflicts.
+ .
+ For more information see:
+ .
+ * Examples on github <http://github.com/mmirman/ImperativeHaskell/blob/master/Main.hs>
+ .
+ * The relevant blog post <http://kormacode.blogspot.com/2011/11/c-style-haskell_10.html>
+
+
Synopsis: A library for writing Imperative style haskell.
Homepage: https://github.com/mmirman/ImperativeHaskell
@@ -37,5 +55,13 @@ Library
Control.Monad.Imperative.Operators,
Control.Monad.Imperative.FunctionFactory
- Extensions: GADTs, EmptyDataDecls, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, TemplateHaskell
-
+ Extensions: GADTs,
+ EmptyDataDecls,
+ GeneralizedNewtypeDeriving,
+ MultiParamTypeClasses,
+ FlexibleInstances,
+ FlexibleContexts,
+ TemplateHaskell,
+ UndecidableInstances,
+ TypeFamilies,
+ FunctionalDependencies
View
1  Main.hs
@@ -1,5 +1,4 @@
{-# LANGUAGE
- DataKinds,
RankNTypes,
TemplateHaskell,
NoMonomorphismRestriction
Please sign in to comment.
Something went wrong with that request. Please try again.