prim 0.1.0.8 → 0.1.0.9
raw patch · 3 files changed
+11/−2 lines, 3 files
Files
- prim.cabal +1/−1
- src/I64.hs +8/−1
- src/Stock/B.hs +2/−0
prim.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: prim homepage: https://github.com/daig/prim#readme-version: 0.1.0.8+version: 0.1.0.9 category: Prelude synopsis: An ergonomic but conservative interface to ghc-prim description:
src/I64.hs view
@@ -1,6 +1,6 @@ {-# language BangPatterns #-} module I64 (I64, module I64) where-import Stock.B (pattern B#)+import Stock.B (pattern B#,(&&), pattern I) import qualified GHC.Classes as GHC (divInt#,modInt#) add,sub,mul, quot, rem :: I64 -> I64 -> I64@@ -44,6 +44,13 @@ div,mod :: I64 {- ^ divisor -} -> I64 {- ^ dividend -} -> I64 {- ^ modulus -} div y x = GHC.divInt# x y; {-# inline div #-} mod y x = GHC.modInt# x y; {-# inline mod #-}+-- | Rounds towards negative infinity. The behavior is undefined if the first argument is zero.+divMod :: I64 {- ^ divisor -} -> I64 {- ^ dividend -} -> (# I64, I64 #) {- ^ (div, mod) -}+divMod y x | B# (gt 0# x) && B# (lt 0# y) = case quotRem y (x -# 1# ) of+ (# q, r #) -> (# q -# 1#, r +# y +# 1# #)+ | B# (lt 0# x) && B# (gt 0# y) = case quotRem y (x +# 1# ) of+ (# q, r #) -> (# q -# 1#, r +# y +# 1# #)+ | I = quotRem y x addC, subC :: I64 -> I64 -> (# I64, B #)
src/Stock/B.hs view
@@ -13,6 +13,8 @@ pattern B# :: Prim.B -> B pattern B# i <- (Prim.dataToTag# -> i) where B# i = isTrue# i +infixr 3 `and`+infixr 2 `or` and, or :: B -> B -> B and = (&&); {-# inline and #-} or = (||); {-# inline or #-}