prim 0.1.0.1 → 0.1.0.2
raw patch · 9 files changed
+89/−10 lines, 9 files
Files
- prim.cabal +2/−2
- src/B.hs +5/−0
- src/I16.hs +18/−1
- src/I32.hs +18/−1
- src/I64.hs +2/−2
- src/I8.hs +18/−1
- src/U16.hs +9/−1
- src/U32.hs +8/−1
- src/U8.hs +9/−1
prim.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: prim homepage: https://github.com/daig/prim#readme-version: 0.1.0.1+version: 0.1.0.2 category: Prelude synopsis: An ergonomic but conservative interface to ghc-prim description: @@ -37,7 +37,7 @@ exposed-modules: Char , I64, I32, I16, I8 , U64, U32, U16, U8- , B8, B16, B32, B64+ , B, B8, B16, B32, B64 , F64, F32 , ST,ST.IO, ST.IO.STM , Ref
+ src/B.hs view
@@ -0,0 +1,5 @@+module B (B, module B) where++fromI64 :: I64 -> B+fromI64 = andI# 1#+
src/I16.hs view
@@ -1,1 +1,18 @@-module I16 (I16) where+module I16 (I16, module I16) where++fromI64 :: I64 -> I16+fromI64 = narrow16Int#++add, sub, mul, quot, rem :: I16 -> I16 -> I16+add y x = narrow16Int# (x +# y)+sub y x = narrow16Int# (x -# y)+mul y x = narrow16Int# (x *# y)+quot y x = narrow16Int# (quotInt# x y)+rem y x = narrow16Int# (remInt# x y)++quotRem :: I16 -> I16 -> (# I16, I16 #)+quotRem y x = case quotRemInt# x y of+ (# q, r #) -> (# narrow16Int# q, narrow16Int# r #)++shiftL# :: I64 -> I16 -> I16+shiftL# i x = narrow16Int# (uncheckedIShiftL# x i)
src/I32.hs view
@@ -1,1 +1,18 @@-module I32 (I32) where+module I32 (I32, module I32) where++fromI64 :: I64 -> I32+fromI64 = narrow32Int#++add, sub, mul, quot, rem :: I32 -> I32 -> I32+add y x = narrow32Int# (x +# y)+sub y x = narrow32Int# (x -# y)+mul y x = narrow32Int# (x *# y)+quot y x = narrow32Int# (quotInt# x y)+rem y x = narrow32Int# (remInt# x y)++quotRem :: I32 -> I32 -> (# I32, I32 #)+quotRem y x = case quotRemInt# x y of+ (# q, r #) -> (# narrow32Int# q, narrow32Int# r #)++shiftL# :: I64 -> I32 -> I32+shiftL# i x = narrow32Int# (uncheckedIShiftL# x i)
src/I64.hs view
@@ -93,13 +93,13 @@ -- | Shift left. Result undefined if shift amount is not -- in the range 0 to word size - 1 inclusive. shiftL# :: I64 -> I64 -> I64-shiftL# = uncheckedIShiftL# +shiftL# i x = uncheckedIShiftL# x i -- |Shift right logical. Result undefined if shift amount is not -- in the range 0 to word size - 1 inclusive. shiftRL# :: I64 -> I64 -> I64-shiftRL# = uncheckedIShiftRL#+shiftRL# i x = uncheckedIShiftRL# x i and, or, xor :: I64 -> I64 -> I64 and = andI# or = orI#
src/I8.hs view
@@ -1,1 +1,18 @@-module I8 (I8) where+module I8 (I8, module I8) where++fromI64 :: I64 -> I8+fromI64 = narrow8Int#++add, sub, mul, quot, rem :: I8 -> I8 -> I8+add y x = narrow8Int# (x +# y)+sub y x = narrow8Int# (x -# y)+mul y x = narrow8Int# (x *# y)+quot y x = narrow8Int# (quotInt# x y)+rem y x = narrow8Int# (remInt# x y)++quotRem :: I8 -> I8 -> (# I8, I8 #)+quotRem y x = case quotRemInt# x y of+ (# q, r #) -> (# narrow8Int# q, narrow8Int# r #)++shiftL# :: I64 -> I8 -> I8+shiftL# i x = narrow8Int# (uncheckedIShiftL# x i)
src/U16.hs view
@@ -1,1 +1,9 @@-module U16 (U16) where+module U16 (U16, module U16) where++fromU64 :: U64 -> U16+fromU64 = narrow16Word#++add, sub, mul :: U16 -> U16 -> U16+add y x = narrow16Word# (plusWord# x y)+sub y x = narrow16Word# (minusWord# x y)+mul y x = narrow16Word# (timesWord# x y)
src/U32.hs view
@@ -1,2 +1,9 @@-module U32 (U32) where+module U32 (U32, module U32) where +fromU64 :: U64 -> U32+fromU64 = narrow32Word#++add, sub, mul :: U32 -> U32 -> U32+add y x = narrow32Word# (plusWord# x y)+sub y x = narrow32Word# (minusWord# x y)+mul y x = narrow32Word# (timesWord# x y)
src/U8.hs view
@@ -1,1 +1,9 @@-module U8 (U8) where+module U8 (U8, module U8) where++fromU64 :: U64 -> U8+fromU64 = narrow8Word#++add, sub, mul :: U8 -> U8 -> U8+add y x = narrow8Word# (plusWord# x y)+sub y x = narrow8Word# (minusWord# x y)+mul y x = narrow8Word# (timesWord# x y)