unpacked-maybe-numeric 0.1.1.0 → 0.1.2.0
raw patch · 16 files changed
+56/−16 lines, 16 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.Maybe.Unpacked.Numeric.Word32: pattern Just :: Word32 -> Maybe
+ Data.Maybe.Unpacked.Numeric.Word32: pattern Nothing :: Maybe
Files
- src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Double.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Float.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Int.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Int16.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Int32.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Int64.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Int8.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Word.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Word16.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Word32.hs +17/−2
- src/Data/Maybe/Unpacked/Numeric/Word64.hs +1/−1
- src/Data/Maybe/Unpacked/Numeric/Word8.hs +1/−1
- test/spec.hs +15/−0
- unpacked-maybe-numeric.cabal +11/−1
src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs view
@@ -86,7 +86,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs view
@@ -86,7 +86,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Double.hs view
@@ -53,7 +53,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Float.hs view
@@ -53,7 +53,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Int.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Int16.hs view
@@ -56,7 +56,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Int32.hs view
@@ -57,7 +57,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Int64.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Int8.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Word.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Word16.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Word32.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} @@ -21,9 +23,13 @@ , toBaseMaybe , fromBaseMaybe++ -- * Patterns+ , pattern Nothing+ , pattern Just ) where -import Prelude hiding (Maybe,maybe)+import Prelude hiding (Maybe,Nothing,Just,maybe) import GHC.Base (build) import GHC.Exts (Word#)@@ -37,6 +43,15 @@ data Maybe = Maybe (# (# #) | Word# #) +pattern Nothing :: Maybe+pattern Nothing = Maybe (# (# #) | #)++pattern Just :: Word32 -> Maybe+pattern Just i <- Maybe (# | (W32# -> i) #)+ where Just (W32# i) = Maybe (# | i #)++{-# COMPLETE Nothing, Just #-}+ instance Eq Maybe where ma == mb = maybe (isNothing mb)@@ -55,7 +70,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Word64.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
src/Data/Maybe/Unpacked/Numeric/Word8.hs view
@@ -55,7 +55,7 @@ instance Read Maybe where readPrec = parens $ nothingP +++ justP where- nothingP = prec 10 $ do+ nothingP = do Ident "nothing" <- lexP return nothing justP = prec 10 $ do
+ test/spec.hs view
@@ -0,0 +1,15 @@+import Control.Monad (when)++import qualified Data.Maybe.Unpacked.Numeric.Word as Word++main :: IO ()+main = do+ putStrLn "A"+ when (showsPrec 12 Word.nothing "" /= "nothing") $ do+ fail "Failed test A"+ putStrLn "B"+ when (showsPrec 6 Word.nothing "" /= "nothing") $ do+ fail "Failed test B"+ putStrLn "C"+ when (showsPrec 11 Word.nothing "" /= "nothing") $ do+ fail "Failed test C"
unpacked-maybe-numeric.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: unpacked-maybe-numeric-version: 0.1.1.0+version: 0.1.2.0 synopsis: maybes of numeric values with fewer indirections description: This library provides one `Maybe` type per the usual numeric types:@@ -50,6 +50,16 @@ , wide-word >= 0.1.0.8 && < 0.2 ghc-options: -Wall -O2 default-language: Haskell2010++test-suite spec+ default-language: Haskell2010+ ghc-options: -Wall+ type: exitcode-stdio-1.0+ main-is: spec.hs+ hs-source-dirs: test+ build-depends:+ , base+ , unpacked-maybe-numeric test-suite laws default-language: Haskell2010