packages feed

imperative-edsl 0.8.2 → 0.8.3

raw patch · 4 files changed

+55/−65 lines, 4 filesdep −constraintsdep ~containersdep ~ghc-primdep ~language-c-quotePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: constraints

Dependency ranges changed: containers, ghc-prim, language-c-quote, microlens-mtl, srcloc

API changes (from Hackage documentation)

- Language.Embedded.CExp: quot_ :: (Integral a, CType a) => CExp a -> CExp a -> CExp a
+ Language.Embedded.CExp: quot_ :: (Eq a, Integral a, CType a) => CExp a -> CExp a -> CExp a

Files

imperative-edsl.cabal view
@@ -1,5 +1,5 @@ name:                imperative-edsl-version:             0.8.2+version:             0.8.3 synopsis:            Deep embedding of imperative programs with code generation description:         Deep embedding of imperative programs with code generation.                      .@@ -86,28 +86,27 @@   build-depends:     array < 0.6,     base >=4 && <5,-    constraints >= 0.9,-    containers >= 0.5.10 && < 0.7,+    containers < 0.7,     data-default-class < 0.2,     deepseq < 1.5,     directory < 1.4,     exception-transformers < 0.5,-    ghc-prim < 0.7,-    language-c-quote >= 0.11.5 && < 0.13,+    ghc-prim < 0.8,+    language-c-quote >= 0.11.5 && < 0.14,     mainland-pretty >= 0.4 && < 0.8,     microlens >= 0.3.0.0 && < 0.5,-    microlens-mtl >= 0.1.8 && < 0.2,+    microlens-mtl >= 0.1.8 && < 0.3,     microlens-th < 0.5,     mtl < 2.3,     process < 1.7,     operational-alacarte >= 0.3,     BoundedChan < 1.1,-    srcloc < 0.6,+    srcloc < 0.7,     syntactic >= 3.8,       -- That version fixes overlap bugs     time >= 1.5.0.1 && < 1.12,     stm >= 2.4 && < 2.6-    +   hs-source-dirs: src  test-suite Tests
src/Language/Embedded/CExp.hs view
@@ -102,6 +102,10 @@ binaryOp BiLe   = Le binaryOp BiGe   = Ge +type SupportCode = forall m . MonadC m => m ()+  -- Only needed because GHC 7.8 can't represent tuple constraints (like+  -- `MonadC`) in Template Haskell.+ -- | Syntactic symbols for C data Sym sig   where@@ -129,16 +133,53 @@     -- Attach extra code to an expression     WithCode :: SupportCode -> Sym (a :-> Full a) -type SupportCode = forall m . MonadC m => m ()-  -- Only needed because GHC 7.8 can't represent tuple constraints (like-  -- `MonadC`) in Template Haskell.+deriveSymbol ''Sym +instance Render Sym+  where+    renderSym (Lit a _)    = a+    renderSym (Const a _)  = a+    renderSym (Fun name _) = name+    renderSym (UOp op)     = show $ unaryOp op+    renderSym (Op op)      = show $ binaryOp op+    renderSym (Cast _)     = "cast"+    renderSym (Var v)      = v+    renderSym (ArrIx (IArrComp arr)) = "ArrIx " ++ arr+    renderSym (ArrIx _)              = "ArrIx ..."+    renderSym (WithCode _) = "WithCode ..."++    renderArgs = renderArgsSmart++instance Equality Sym+  where+    equal = equalDefault+    hash  = hashDefault++instance StringTree Sym++instance Symbol T where symSig (T s) = symSig s++instance Render T+  where+    renderSym (T s)     = renderSym s+    renderArgs as (T s) = renderArgs as s++instance Equality T+  where+    equal (T s) (T t) = equal s t+    hash (T s)        = hash s++instance StringTree T+  where+    stringTreeSym as (T s) = stringTreeSym as s+ data T sig   where     T :: CType (DenResult sig) => { unT :: Sym sig } -> T sig  -- | C expression newtype CExp a = CExp {unCExp :: ASTF T a}+  deriving (Eq)  instance Syntactic (CExp a)   where@@ -360,7 +401,7 @@     recip = error "recip not implemented for CExp"  -- | Integer division truncated toward zero-quot_ :: (Integral a, CType a) => CExp a -> CExp a -> CExp a+quot_ :: (Eq a, Integral a, CType a) => CExp a -> CExp a -> CExp a quot_ (LitP 0) b = 0 quot_ a (LitP 1) = a quot_ a b@@ -479,54 +520,4 @@ -- | Array indexing (#!) :: (CType a, Integral i, Ix i) => IArr i a -> CExp i -> CExp a arr #! i = sugarSym (T $ ArrIx arr) i--------------------------------------------------------------------------------------- Instances-----------------------------------------------------------------------------------deriveSymbol ''Sym--instance Render Sym-  where-    renderSym (Lit a _)    = a-    renderSym (Const a _)  = a-    renderSym (Fun name _) = name-    renderSym (UOp op)     = show $ unaryOp op-    renderSym (Op op)      = show $ binaryOp op-    renderSym (Cast _)     = "cast"-    renderSym (Var v)      = v-    renderSym (ArrIx (IArrComp arr)) = "ArrIx " ++ arr-    renderSym (ArrIx _)              = "ArrIx ..."-    renderSym (WithCode _) = "WithCode ..."--    renderArgs = renderArgsSmart--instance Equality Sym-  where-    equal = equalDefault-    hash  = hashDefault--instance StringTree Sym--instance Symbol T where symSig (T s) = symSig s--instance Render T-  where-    renderSym (T s)     = renderSym s-    renderArgs as (T s) = renderArgs as s--instance Equality T-  where-    equal (T s) (T t) = equal s t-    hash (T s)        = hash s--instance StringTree T-  where-    stringTreeSym as (T s) = stringTreeSym as s--deriving instance Eq (CExp a)-  -- Must be placed here due to the sequential dependencies introduced by-  -- Template Haskell 
src/Language/Embedded/Imperative/Frontend.hs view
@@ -12,9 +12,9 @@  import Data.Array.IO import Data.IORef+import Data.Kind (Constraint) import Data.Typeable import System.IO.Unsafe-import Data.Constraint  import Control.Monad.Operational.Higher import System.IO.Fake
tests/Imperative.hs view
@@ -151,7 +151,7 @@ testSwap1 = do     arr1 :: Arr Word32 Int32 <- constArr [1,2,3,4]     arr2 :: Arr Word32 Int32 <- constArr [11,12,13,14]-    unsafeSwap arr1 arr2+    unsafeSwapArr arr1 arr2     sequence_ [getArr arr1 i >>= printf "%d " | i <- map fromInteger [0..3]]     printf "\n" @@ -162,7 +162,7 @@     arr2 :: Arr Word32 Int32 <- newArr n     copyArr (arr2,0) (arr1,0) 4     setArr arr2 2 22-    unsafeSwap arr1 arr2+    unsafeSwapArr arr1 arr2     sequence_ [getArr arr1 i >>= printf "%d " | i <- map fromInteger [0..3]]     printf "\n"     sequence_ [getArr arr2 i >>= printf "%d " | i <- map fromInteger [0..3]]