packages feed

raw-feldspar 0.3.1 → 0.4

raw patch · 4 files changed

+38/−33 lines, 4 filesdep ~constraintsdep ~imperative-edsldep ~language-c-quote

Dependency ranges changed: constraints, imperative-edsl, language-c-quote, template-haskell

Files

raw-feldspar.cabal view
@@ -1,5 +1,5 @@ name:                raw-feldspar-version:             0.3.1+version:             0.4 synopsis:            Resource-Aware Feldspar description:         An implementation of the Feldspar EDSL with focus on                      resource-awareness.@@ -94,18 +94,18 @@   build-depends:     array < 0.6,     base < 5,-    constraints < 0.12,+    constraints < 0.14,     containers < 0.7,     data-default-class < 0.2,     data-hash < 0.3,-    imperative-edsl >= 0.8 && < 0.9,-    language-c-quote < 0.13,+    imperative-edsl >= 0.9 && < 0.10,+    language-c-quote < 0.14,     mtl < 2.3,     operational-alacarte,     prelude-edsl >= 0.4,     syntactic >= 3.8,       -- That version fixes overlap bugs-    template-haskell < 2.17+    template-haskell < 2.18    if impl(ghc == 8.0.*)     build-depends:
src/Feldspar/Data/Vector.hs view
@@ -364,7 +364,7 @@  -- | Take the head of a non-empty vector head :: Pully vec a => vec -> a-head = (!0)+head = (! 0)  tail :: Pully vec a => vec -> Pull a tail = drop 1
src/Feldspar/Representation.hs view
@@ -237,8 +237,6 @@     evalSym (GuardVal _ msg) = \cond a ->         if cond then a else error $ "Feldspar assertion failure: " ++ msg -instance EvalEnv ExtraPrimitive env- instance Equality ExtraPrimitive   where     equal DivBalanced    DivBalanced    = True@@ -248,8 +246,6 @@     hash DivBalanced    = hashInt 1     hash (GuardVal _ _) = hashInt 2 -instance StringTree ExtraPrimitive- -- | For loop data ForLoop sig   where@@ -261,10 +257,6 @@     evalSym ForLoop = \len init body ->         foldl (flip body) init $ genericTake len [0..] -instance EvalEnv ForLoop env--instance StringTree ForLoop- -- | Interaction with the IO layer data Unsafe sig   where@@ -275,14 +267,10 @@   where     renderSym (UnsafePerform _) = "UnsafePerform ..." -instance StringTree Unsafe- instance Eval Unsafe   where     evalSym s = error $ "eval: cannot evaluate unsafe operation " ++ renderSym s -instance EvalEnv Unsafe env- -- | 'equal' always returns 'False' instance Equality Unsafe   where@@ -361,23 +349,14 @@     => sub sig -> f sugarSymFeldPrim = sugarSymDecor $ ValT $ Single primTypeRep --- | Evaluate a closed expression-eval :: (Syntactic a, Domain a ~ FeldDomain) => a -> Internal a-eval = evalClosed . desugar-  -- Note that a `Syntax` constraint would rule out evaluating functions- instance Imp.FreeExp Data   where     type FreePred Data = PrimType'     constExp = sugarSymFeldPrim . Lit     varExp   = sugarSymFeldPrim . FreeVar -instance Imp.EvalExp Data-  where-    evalExp = eval  - -------------------------------------------------------------------------------- -- * Monadic computations --------------------------------------------------------------------------------@@ -432,3 +411,32 @@  deriveSymbol ''Unsafe +++--------------------------------------------------------------------------------+-- * Interpretation+--------------------------------------------------------------------------------++-- The stuff below depends on the TH-generated instances. From GHC 9, it seems+-- that generated instances are only in scope after the splice. The alternative+-- to move the splices up into the code is not possible (at least not easily)+-- because of the mutual dependencies between the different types. (Definitions+-- that occur after a splice are not in scope before the splice.)++instance EvalEnv ExtraPrimitive env+instance StringTree ExtraPrimitive++instance EvalEnv ForLoop env+instance StringTree ForLoop++instance EvalEnv Unsafe env+instance StringTree Unsafe++-- | Evaluate a closed expression+eval :: (Syntactic a, Domain a ~ FeldDomain) => a -> Internal a+eval = evalClosed . desugar+  -- Note that a `Syntax` constraint would rule out evaluating functions++instance Imp.EvalExp Data+  where+    evalExp = eval
src/Feldspar/Run/Frontend.hs view
@@ -33,17 +33,14 @@ -- -- This is generally an unsafe operation. E.g. it can be used to make a -- reference to a data structure escape the scope of the data.------ The 'IsPointer' class ensures that the operation is only possible for types--- that are represented as pointers in C.-unsafeSwap :: IsPointer a => a -> a -> Run ()+unsafeSwap :: Ptr a -> Ptr a -> Run () unsafeSwap a b = Run $ Imp.unsafeSwap a b  -- | Like 'unsafeSwap' but for arrays. The why we cannot use 'unsafeSwap' -- directly is that 'Arr' cannot be made an instance of 'IsPointer'. unsafeSwapArr :: Arr a -> Arr a -> Run () unsafeSwapArr arr1 arr2 = Run $ sequence_ $-    zipListStruct Imp.unsafeSwap (unArr arr1) (unArr arr2)+    zipListStruct Imp.unsafeSwapArr (unArr arr1) (unArr arr2)   -- An alternative would be to make a new `IsPointer` class for Feldspar  @@ -66,7 +63,7 @@  class PrintfType r   where-    fprf :: Handle -> String -> [Imp.PrintfArg Data] -> r+    fprf :: Handle -> String -> [Imp.PrintfArg Data PrimType'] -> r  instance (a ~ ()) => PrintfType (Run a)   where