packages feed

circ 0.0.2 → 0.0.3

raw patch · 2 files changed

+20/−7 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Language.CIRC.Runtime: idId :: Id -> CIRC Int
- Language.CIRC.Runtime: type CIRC = State Int
+ Language.CIRC.Runtime: type CIRC = State (Int, [(String, Int)])

Files

Language/CIRC/Runtime.hs view
@@ -5,20 +5,23 @@   , runCIRC   , Id   , newId+  , idId   ) where  import Control.Monad.State  -- | The CIRC transform monad.  Used to create fresh ids.-type CIRC = State Int+type CIRC = State (Int, [(String, Int)])  -- | Evaluates a CIRC transform. evalCIRC :: CIRC a -> Int -> a-evalCIRC = evalState+evalCIRC a i = evalState a (i, [])  -- | Evaluates a CIRC transform, also returning the fresh next id. runCIRC :: CIRC a -> Int -> (a, Int)-runCIRC = runState+runCIRC a i = (b, j)+  where+  (b, (j, _)) = runState a (i, [])  -- | Identifiers. type Id = String@@ -26,7 +29,17 @@ -- | Produces a fresh id. newId :: CIRC Id newId = do-  id <- get-  put $ id + 1-  return $ "__" ++ show id+  (i, table) <- get+  put (i + 1, table)+  return $ "__" ++ show i++-- | Returns a unqiue int for a given id.+idId  :: Id -> CIRC Int+idId name = do+  (i, table) <- get+  case lookup name table of+    Nothing -> do+      put (i + 1, (name, i) : table)+      return i+    Just i -> return i 
circ.cabal view
@@ -1,5 +1,5 @@ name:                circ-version:             0.0.2+version:             0.0.3 synopsis:            A Compiler IR Compiler. description:         A Compiler IR Compiler. license:             BSD3