ersatz 0.2.6 → 0.2.6.1
raw patch · 5 files changed
+58/−5 lines, 5 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Ersatz.Bits: full_adder :: Bit -> Bit -> Bit -> (Bit, Bit)
+ Ersatz.Bits: half_adder :: Bit -> Bit -> (Bit, Bit)
+ Ersatz.Bits: instance [safe] Num Bit1
+ Ersatz.Bits: instance [safe] Num Bit2
+ Ersatz.Variable: class GVariable f
+ Ersatz.Variable: gexists :: (GVariable f, MonadState s m, HasSAT s) => m (f a)
+ Ersatz.Variable: gforall :: (GVariable f, MonadState s m, HasQSAT s) => m (f a)
Files
- .travis.yml +6/−1
- CHANGELOG.md +4/−0
- ersatz.cabal +8/−4
- src/Ersatz/Bits.hs +39/−0
- src/Ersatz/Variable.hs +1/−0
.travis.yml view
@@ -6,13 +6,18 @@ # Try installing some of the build-deps with apt-get for speed. - travis/cabal-apt-install $mode+ - cabal install happy packunused packdeps+ - export PATH=~/.cabal/bin:$PATH install: - cabal configure -flib-Werror $mode - cabal build script:- - $script && hlint src --cpp-define HLINT+ - $script+ - packdeps ersatz.cabal+ - packunused+ - hlint src --cpp-define HLINT notifications: irc:
CHANGELOG.md view
@@ -1,3 +1,7 @@+0.2.6.1+-----+* Exported `Ersatz.Variable.GVariable`+ 0.2.6 ----- * `temporary 1.2` support
ersatz.cabal view
@@ -1,5 +1,5 @@ name: ersatz-version: 0.2.6+version: 0.2.6.1 license: BSD3 license-file: LICENSE author: Edward A. Kmett, Johan Kiviniemi@@ -170,7 +170,6 @@ bytestring >= 0.9 && < 0.12, containers >= 0.2.0.1 && < 0.6, data-default >= 0.5 && < 0.6,- ghc-prim, lens >= 3.8 && < 5, mtl >= 1.1 && < 2.2, process >= 1.1 && < 1.3,@@ -178,6 +177,9 @@ transformers == 0.3.*, unordered-containers == 0.2.* + if impl(ghc >= 7.4 && < 7.6)+ build-depends: ghc-prim+ exposed-modules: Ersatz Ersatz.Bit@@ -207,10 +209,11 @@ base < 5, containers, ersatz,- ghc-prim, lens, mtl, parsec >= 3.1 && < 3.2+ if impl(ghc >= 7.4 && < 7.6)+ build-depends: ghc-prim else buildable: False main-is: Main.hs@@ -229,8 +232,9 @@ array, base < 5, ersatz,- ghc-prim, mtl+ if impl(ghc >= 7.4 && < 7.6)+ build-depends: ghc-prim else buildable: False default-language: Haskell2010
src/Ersatz/Bits.hs view
@@ -13,6 +13,7 @@ -------------------------------------------------------------------- module Ersatz.Bits ( Bit1(..), Bit2(..), Bit3(..), Bit4(..), Bit5(..), Bit6(..), Bit7(..), Bit8(..)+ , full_adder, half_adder ) where import Prelude hiding ((&&), (||), and, or, not)@@ -178,3 +179,41 @@ boolToNum False = 0 boolToNum True = 1 {-# INLINE boolToNum #-}++instance Num Bit1 where+ Bit1 a + Bit1 b = Bit1 (xor a b)+ Bit1 a * Bit1 b = Bit1 (a && b)+ Bit1 a - Bit1 b = Bit1 (xor a b)+ negate a = a+ abs a = a+ signum a = a+ fromInteger = Bit1 . bool . odd++full_adder :: Bit -> Bit -> Bit -> (Bit, Bit)+full_adder a b cin = (s2, c1 || c2)+ where (s1,c1) = half_adder a b+ (s2,c2) = half_adder s1 cin++half_adder :: Bit -> Bit -> (Bit, Bit)+half_adder a b = (a `xor` b, a && b)++instance Num Bit2 where+ Bit2 a2 a1 + Bit2 b2 b1 = Bit2 s2 s1 where+ (s1,c2) = half_adder a1 b1+ (s2,_) = full_adder a2 b2 c2+ Bit2 a2 a1 * Bit2 b2 b1 = Bit2 ((a1 && b2) `xor` (a2 && b1)) (a1 && b1)+ -- wallace tree+ --+ -- XX+ -- XX+ -- ----+ -- XXX+ -- X+ -- ----+ -- XXXX+ --+ -- But we only need the first 2 bits+ negate (Bit2 a b) = Bit2 (not a) (not b) + 1+ abs a = a+ signum (Bit2 a b) = Bit2 false (a || b)+ fromInteger k = Bit2 (bool (k .&. 2 /= 0)) (bool (k .&. 1 /= 0))
src/Ersatz/Variable.hs view
@@ -14,6 +14,7 @@ -------------------------------------------------------------------- module Ersatz.Variable ( Variable(..)+ , GVariable(..) ) where import Control.Monad