packages feed

clash-prelude 0.10.9 → 0.10.10

raw patch · 6 files changed

+79/−20 lines, 6 files

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for [`clash-prelude` package](http://hackage.haskell.org/package/clash-prelude) +## 0.10.10 *July 15th 2016*+* Fixes bugs:+  * `shrink` functions for numeric types throw exceptions [#153](https://github.com/clash-lang/clash-compiler/issues/153)+  * CLaSH compiler sees internals of numeric types in their Show functions+ ## 0.10.9 *June 9th 2016* * Fixes bugs:   * `Eq` instance of `Vec` sometimes not synthesisable
clash-prelude.cabal view
@@ -1,5 +1,5 @@ Name:                 clash-prelude-Version:              0.10.9+Version:              0.10.10 Synopsis:             CAES Language for Synchronous Hardware - Prelude library Description:   CλaSH (pronounced ‘clash’) is a functional hardware description language that@@ -154,13 +154,13 @@    Build-depends:      array                     >= 0.5.1.0 && < 0.6,                       base                      >= 4.8.0.0 && < 5,-                      data-default              >= 0.5.3   && < 0.7,+                      data-default              >= 0.5.3   && < 0.8,                       integer-gmp               >= 0.5.1.0 && < 1.1,                       ghc-prim                  >= 0.3.1.0 && < 0.6,                       ghc-typelits-extra        >= 0.1     && < 0.2,                       ghc-typelits-natnormalise >= 0.4.1   && < 0.5,                       lens                      >= 4.9     && < 4.15,-                      QuickCheck                >= 2.7     && < 2.9,+                      QuickCheck                >= 2.7     && < 2.10,                       reflection                >= 2       && < 2.2,                       singletons                >= 1.0     && < 3.0,                       template-haskell          >= 2.9.0.0 && < 2.12
src/CLaSH/Sized/Internal/BitVector.hs view
@@ -89,6 +89,8 @@   , popCountBV     -- ** Resize   , resize#+    -- ** QuickCheck+  , shrinkSizedUnsigned   ) where @@ -105,7 +107,7 @@ import Language.Haskell.TH.Syntax (Lift(..)) import Numeric                    (readInt) import Test.QuickCheck.Arbitrary  (Arbitrary (..), CoArbitrary (..),-                                   arbitrarySizedBoundedIntegral,+                                   arbitraryBoundedIntegral,                                    coarbitraryIntegral, shrinkIntegral)  import CLaSH.Class.Num            (ExtendingNum (..), SaturatingNum (..),@@ -139,7 +141,7 @@  -- * Instances instance KnownNat n => Show (BitVector n) where-  show bv@(BV i) = reverse . underScore . reverse $ showBV (natVal bv) i []+  show bv = reverse . underScore . reverse $ showBV (natVal bv) (toInteger# bv) []     where       showBV 0 _ s = s       showBV n v s = let (a,b) = divMod v 2@@ -572,8 +574,20 @@       (rL,rR) = split# r  instance KnownNat n => Arbitrary (BitVector n) where-  arbitrary = arbitrarySizedBoundedIntegral-  shrink    = shrinkIntegral+  arbitrary = arbitraryBoundedIntegral+  shrink    = shrinkSizedUnsigned++-- | 'shrink' for sized unsigned types+shrinkSizedUnsigned :: (KnownNat n, Integral (p n)) => p n -> [p n]+shrinkSizedUnsigned x | natVal x < 2 = case toInteger x of+                                         1 -> [0]+                                         _ -> []+                      -- 'shrinkIntegral' uses "`quot` 2", which for sized types+                      -- less than 2 bits wide results in a division by zero.+                      --+                      -- See: https://github.com/clash-lang/clash-compiler/issues/153+                      | otherwise    = shrinkIntegral x+{-# INLINE shrinkSizedUnsigned #-}  instance KnownNat n => CoArbitrary (BitVector n) where   coarbitrary = coarbitraryIntegral
src/CLaSH/Sized/Internal/Index.hs view
@@ -67,7 +67,7 @@                                    natVal) import GHC.TypeLits.Extra         (CLog) import Test.QuickCheck.Arbitrary  (Arbitrary (..), CoArbitrary (..),-                                   arbitrarySizedBoundedIntegral,+                                   arbitraryBoundedIntegral,                                    coarbitraryIntegral, shrinkIntegral)  import CLaSH.Class.BitPack            (BitPack (..))@@ -269,7 +269,14 @@ decIndex n = appT (conT ''Index) (litT $ numTyLit n)  instance Show (Index n) where-  show (I n) = show n+  showsPrec p ix = showsPrec p (toInteger# ix)+  show ix = show (toInteger# ix)+  -- We cannot say:+  --+  -- > show (I i) = show i+  --+  -- Because GHC translates that to a cast from Index to Integer,+  -- which the CLaSH compiler can (currently) not handle.  -- | None of the 'Read' class' methods are synthesisable. instance KnownNat n => Read (Index n) where@@ -279,8 +286,16 @@   def = fromInteger# 0  instance KnownNat n => Arbitrary (Index n) where-  arbitrary = arbitrarySizedBoundedIntegral-  shrink    = shrinkIntegral+  arbitrary = arbitraryBoundedIntegral+  shrink    = shrinkIndex++shrinkIndex :: KnownNat n => Index n -> [Index n]+shrinkIndex x | natVal x < 3 = case toInteger x of+                                 1 -> [0]+                                 _ -> []+              -- 'shrinkIntegral' uses "`quot` 2", which for 'Index' types with+              -- an upper bound less than 2 results in an error.+              | otherwise    = shrinkIntegral x  instance KnownNat n => CoArbitrary (Index n) where   coarbitrary = coarbitraryIntegral
src/CLaSH/Sized/Internal/Signed.hs view
@@ -88,7 +88,7 @@ import Language.Haskell.TH            (TypeQ, appT, conT, litT, numTyLit, sigE) import Language.Haskell.TH.Syntax     (Lift(..)) import Test.QuickCheck.Arbitrary      (Arbitrary (..), CoArbitrary (..),-                                       arbitrarySizedBoundedIntegral,+                                       arbitraryBoundedIntegral,                                        coarbitraryIntegral, shrinkIntegral)  import CLaSH.Class.BitPack            (BitPack (..))@@ -147,7 +147,14 @@ size# bv = fromInteger (natVal bv)  instance Show (Signed n) where-  show (S n) = show n+  showsPrec p s = showsPrec p (toInteger# s)+  show s = show (toInteger# s)+  -- We cannot say:+  --+  -- > show (S i) = show i+  --+  -- Because GHC translates that to a cast from Signed to Integer,+  -- which the CLaSH compiler can (currently) not handle.  -- | None of the 'Read' class' methods are synthesisable. instance KnownNat n => Read (Signed n) where@@ -481,8 +488,19 @@ minBoundSym# = minBound# +# fromInteger# 1  instance KnownNat n => Arbitrary (Signed n) where-  arbitrary = arbitrarySizedBoundedIntegral-  shrink    = shrinkIntegral+  arbitrary = arbitraryBoundedIntegral+  shrink    = shrinkSizedSigned++shrinkSizedSigned :: (KnownNat n, Integral (p n)) => p n -> [p n]+shrinkSizedSigned x | natVal x < 2 = case toInteger x of+                                       0 -> []+                                       _ -> [0]+                    -- 'shrinkIntegral' uses "`quot` 2", which for sized types+                    -- less than 2 bits wide results in a division by zero.+                    --+                    -- See: https://github.com/clash-lang/clash-compiler/issues/153+                    | otherwise    = shrinkIntegral x+{-# INLINE shrinkSizedSigned #-}  instance KnownNat n => CoArbitrary (Signed n) where   coarbitrary = coarbitraryIntegral
src/CLaSH/Sized/Internal/Unsigned.hs view
@@ -81,8 +81,8 @@ import Language.Haskell.TH            (TypeQ, appT, conT, litT, numTyLit, sigE) import Language.Haskell.TH.Syntax     (Lift(..)) import Test.QuickCheck.Arbitrary      (Arbitrary (..), CoArbitrary (..),-                                       arbitrarySizedBoundedIntegral,-                                       coarbitraryIntegral, shrinkIntegral)+                                       arbitraryBoundedIntegral,+                                       coarbitraryIntegral)  import CLaSH.Class.BitPack            (BitPack (..)) import CLaSH.Class.Num                (ExtendingNum (..), SaturatingNum (..),@@ -136,7 +136,14 @@ size# u = fromInteger (natVal u)  instance Show (Unsigned n) where-  show (U i) = show i+  showsPrec p u = showsPrec p (toInteger# u)+  show u = show (toInteger# u)+  -- We cannot say:+  --+  -- > show (U i) = show i+  --+  -- Because GHC translates that to a cast from Unsigned to Integer,+  -- which the CLaSH compiler can (currently) not handle  -- | None of the 'Read' class' methods are synthesisable. instance KnownNat n => Read (Unsigned n) where@@ -419,8 +426,8 @@       (rL,rR) = split r  instance KnownNat n => Arbitrary (Unsigned n) where-  arbitrary = arbitrarySizedBoundedIntegral-  shrink    = shrinkIntegral+  arbitrary = arbitraryBoundedIntegral+  shrink    = BV.shrinkSizedUnsigned  instance KnownNat n => CoArbitrary (Unsigned n) where   coarbitrary = coarbitraryIntegral