packages feed

clash-lib 0.6.2 → 0.6.3

raw patch · 5 files changed

+31/−12 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ CLaSH.Rewrite.Types: instance Control.Monad.Fix.MonadFix (CLaSH.Rewrite.Types.RewriteMonad extra)
- CLaSH.Rewrite.Types: bindings :: Lens' (RewriteState extra_a3zEK) (HashMap TmName (Type, Term))
+ CLaSH.Rewrite.Types: bindings :: Lens' (RewriteState extra_aWNM) (HashMap TmName (Type, Term))
- CLaSH.Rewrite.Types: curFun :: Lens' (RewriteState extra_a3zEK) TmName
+ CLaSH.Rewrite.Types: curFun :: Lens' (RewriteState extra_aWNM) TmName
- CLaSH.Rewrite.Types: extra :: Lens (RewriteState extra_a3zEK) (RewriteState extra_a3zI7) extra_a3zEK extra_a3zI7
+ CLaSH.Rewrite.Types: extra :: Lens (RewriteState extra_aWNM) (RewriteState extra_aWQY) extra_aWNM extra_aWQY
- CLaSH.Rewrite.Types: nameCounter :: Lens' (RewriteState extra_a3zEK) Int
+ CLaSH.Rewrite.Types: nameCounter :: Lens' (RewriteState extra_aWNM) Int
- CLaSH.Rewrite.Types: transformCounter :: Lens' (RewriteState extra_a3zEK) Int
+ CLaSH.Rewrite.Types: transformCounter :: Lens' (RewriteState extra_aWNM) Int
- CLaSH.Rewrite.Types: uniqSupply :: Lens' (RewriteState extra_a3zEK) Supply
+ CLaSH.Rewrite.Types: uniqSupply :: Lens' (RewriteState extra_aWNM) Supply

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog for the [`clash-lib`](http://hackage.haskell.org/package/clash-lib) package +## 0.6.3 *October 24th 2015*+* New features:+  * Improve DEC transformation: consider alternatives before the subject when checking for disjoint expressions.+* Fixes bugs:+  * DEC: don't generate single-branch case-expressions [#90](https://github.com/clash-lang/clash-compiler/issues/90)+ ## 0.6.2 *October 21st 2015* * Fixes bugs:   * DEC: Subject and alternatives are not disjoint [#88](https://github.com/clash-lang/clash-compiler/issues/88)
clash-lib.cabal view
@@ -1,5 +1,5 @@ Name:                 clash-lib-Version:              0.6.2+Version:              0.6.3 Synopsis:             CAES Language for Synchronous Hardware - As a Library Description:   CλaSH (pronounced ‘clash’) is a functional hardware description language that
src/CLaSH/Netlist.hs view
@@ -199,7 +199,7 @@                                         -- When element and subject have the same HW-type,                                         -- then the projections is just the identity                                         | otherwise      -> Just (DC (Void,0))-        _ -> Nothing+        _ -> error $ $(curLoc) ++ "Not in normal form: Unexpected pattern in case-projection: " ++ showDoc e       extractExpr = Identifier (maybe altVarId (const selId) modifier) modifier   return (decls ++ [Assignment dstId extractExpr]) 
src/CLaSH/Normalize/DEC.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveFoldable    #-} {-# LANGUAGE DeriveFunctor     #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecursiveDo       #-} {-# LANGUAGE TemplateHaskell   #-} {-# LANGUAGE TupleSections     #-} {-# LANGUAGE ViewPatterns      #-}@@ -51,8 +52,9 @@ import qualified Data.Set                         as Set import qualified Data.Set.Lens                    as Lens -import           Unbound.Generics.LocallyNameless (Bind, bind, embed, rec,-                                                   unbind, unembed, unrec)+import           Unbound.Generics.LocallyNameless (Bind, bind, embed, fv, unbind,+                                                   unembed, unrec)+import qualified Unbound.Generics.LocallyNameless as Unbound  -- internal import CLaSH.Core.DataCon    (DataCon, dcTag)@@ -116,10 +118,10 @@   -> RewriteMonad NormalizeState                   (Term,[(Term,CaseTree [(Either Term Type)])]) collectGlobals inScope substitution seen (Case scrut ty alts) = do-  (scrut',collected)  <- collectGlobals     inScope substitution seen scrut-  (alts' ,collected') <- collectGlobalsAlts inScope substitution-                                            (map fst collected ++ seen)-                                            scrut' alts+  rec (alts' ,collected)  <- collectGlobalsAlts inScope substitution seen scrut'+                                                alts+      (scrut',collected') <- collectGlobals inScope substitution+                                            (map fst collected ++ seen) scrut   return (Case scrut' ty alts',collected ++ collected')  collectGlobals inScope substitution seen e@(collectArgs -> (fun, args@(_:_)))@@ -149,7 +151,7 @@   (lbs',collected')   <- collectGlobalsLbs inScope substitution                                            (map fst collected ++ seen)                                            lbs-  return (Letrec (bind (rec lbs') body')+  return (Letrec (bind (Unbound.rec lbs') body')          ,map (second (LB lbs')) (collected ++ collected')          ) @@ -262,7 +264,7 @@         disJointSelProj argTys cs''     let newArgs = mkDJArgs 0 common uncommonProjections     case uncommonCaseM of-      Just lb -> return (Letrec (bind (rec [lb]) (mkApps fun newArgs)))+      Just lb -> return (Letrec (bind (Unbound.rec [lb]) (mkApps fun newArgs)))       Nothing -> return (mkApps fun newArgs)  -- | Create a single selector for all the representable uncommon arguments by@@ -350,7 +352,14 @@         _ -> head tms      go (LB lb ct) =-      Letrec (bind (rec lb) (go ct))+      Letrec (bind (Unbound.rec lb) (go ct))++    go (Branch scrut [(p,ct)]) =+      let ct' = go ct+          alt = bind p ct'+      in  case Lens.setOf termFreeIds ct' == Lens.setOf fv alt of+            True -> ct'+            _    -> Case scrut ty [alt]      go (Branch scrut pats) =       Case scrut ty (map (\(p,ct) -> bind p (go ct)) pats)
src/CLaSH/Rewrite/Types.hs view
@@ -8,8 +8,9 @@  import Control.Concurrent.Supply             (Supply, freshId) import Control.Lens                          (use, (.=), (<<%=))-import Control.Monad.Reader                  (MonadReader (..)) import Control.Monad+import Control.Monad.Fix                     (MonadFix (..), fix)+import Control.Monad.Reader                  (MonadReader (..)) import Control.Monad.State                   (MonadState (..)) import Control.Monad.Writer                  (MonadWriter (..)) import Data.HashMap.Strict                   (HashMap)@@ -135,6 +136,9 @@    ask       = R (\r s -> (r,s,mempty))    local f m = R (\r s -> runR m (f r) s)    reader f  = R (\r s -> (f r,s,mempty))++instance MonadFix (RewriteMonad extra) where+  mfix f = R (\r s -> fix $ \ ~(a,_,_) -> runR (f a) r s)  -- | Monadic action that transforms a term given a certain context type Transform m = [CoreContext] -> Term -> m Term