From 2d484d0c5b59e88899950bed235bbae1be301c58 Mon Sep 17 00:00:00 2001 From: Brian McKeon Date: Thu, 1 Feb 2024 20:38:14 -0500 Subject: [PATCH] Reformatted. Added workflows. --- .github/CODEOWNERS | 1 + .github/workflows/build.yaml | 12 +++ .github/workflows/release.yaml | 12 +++ .gitignore | 1 + CHANGELOG.md | 5 ++ ChangeLog.md | 5 -- Setup.hs | 2 - fourmolu.yaml | 51 ++++++++++++ .../Maybe/Unpacked/Numeric/Complex/Double.hs | 78 +++++++++---------- .../Maybe/Unpacked/Numeric/Complex/Float.hs | 76 +++++++++--------- src/Data/Maybe/Unpacked/Numeric/Double.hs | 62 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Float.hs | 62 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Int.hs | 63 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Int16.hs | 75 +++++++++--------- src/Data/Maybe/Unpacked/Numeric/Int32.hs | 73 +++++++++-------- src/Data/Maybe/Unpacked/Numeric/Int64.hs | 63 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Int8.hs | 71 +++++++++-------- src/Data/Maybe/Unpacked/Numeric/Word.hs | 65 ++++++++-------- src/Data/Maybe/Unpacked/Numeric/Word128.hs | 66 ++++++++-------- src/Data/Maybe/Unpacked/Numeric/Word16.hs | 61 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Word32.hs | 66 ++++++++-------- src/Data/Maybe/Unpacked/Numeric/Word64.hs | 63 +++++++-------- src/Data/Maybe/Unpacked/Numeric/Word8.hs | 61 +++++++-------- test/laws.hs | 54 +++++++------ unpacked-maybe-numeric.cabal | 77 +++++++++--------- 25 files changed, 634 insertions(+), 591 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 CHANGELOG.md delete mode 100644 ChangeLog.md delete mode 100644 Setup.hs create mode 100644 fourmolu.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f6c0b22 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@byteverse/l3c diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..085bbaf --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,12 @@ +name: build +on: + pull_request: + branches: + - "*" + +jobs: + call-workflow: + uses: byteverse/.github/.github/workflows/build.yaml@main + secrets: inherit + with: + release: false diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..bd0bbd5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,12 @@ +name: release +on: + push: + tags: + - "*" + +jobs: + call-workflow: + uses: byteverse/.github/.github/workflows/build.yaml@main + secrets: inherit + with: + release: true diff --git a/.gitignore b/.gitignore index 0ba1124..2bf47ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode/ dist dist-* cabal-dev diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..486b993 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog for unpacked-maybe-numeric + +## 0.1.1.0 -- 2019-09-28 + +* Add module for `Word128`-variant of `Maybe`. diff --git a/ChangeLog.md b/ChangeLog.md deleted file mode 100644 index e026a68..0000000 --- a/ChangeLog.md +++ /dev/null @@ -1,5 +0,0 @@ -# Changelog for unpacked-maybe-numeric - -## [0.1.1.0] - 2019-09-28 - -- Add module for `Word128`-variant of `Maybe`. diff --git a/Setup.hs b/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000..40cd005 --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1,51 @@ +# Number of spaces per indentation step +indentation: 2 + +# Max line length for automatic line breaking +column-limit: 200 + +# Styling of arrows in type signatures (choices: trailing, leading, or leading-args) +function-arrows: trailing + +# How to place commas in multi-line lists, records, etc. (choices: leading or trailing) +comma-style: leading + +# Styling of import/export lists (choices: leading, trailing, or diff-friendly) +import-export-style: leading + +# Whether to full-indent or half-indent 'where' bindings past the preceding body +indent-wheres: false + +# Whether to leave a space before an opening record brace +record-brace-space: true + +# Number of spaces between top-level declarations +newlines-between-decls: 1 + +# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact) +haddock-style: multi-line + +# How to print module docstring +haddock-style-module: null + +# Styling of let blocks (choices: auto, inline, newline, or mixed) +let-style: auto + +# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space) +in-style: right-align + +# Whether to put parentheses around a single constraint (choices: auto, always, or never) +single-constraint-parens: always + +# Output Unicode syntax (choices: detect, always, or never) +unicode: never + +# Give the programmer more choice on where to insert blank lines +respectful: true + +# Fixity information for operators +fixities: [] + +# Module reexports Fourmolu should know about +reexports: [] + diff --git a/src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs b/src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs index c81cd9e..9ffd79a 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Complex/Double.hs @@ -1,20 +1,14 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Complex.Double - ( Complex(..) + ( Complex (..) , toBaseComplex , fromBaseComplex - - , Maybe(..) + , Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -22,20 +16,19 @@ module Data.Maybe.Unpacked.Numeric.Complex.Double , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where - -import Prelude hiding (Maybe,maybe) + ) where + +import Prelude hiding (Maybe, maybe) import qualified Data.Complex as C import GHC.Base (build) -import GHC.Exts (Double#,Double(D#),(==##)) +import GHC.Exts (Double (D#), Double#, (==##)) -import GHC.Read (Read(readPrec), expectP) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec), expectP) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P data Complex = Complex Double# Double# @@ -44,20 +37,20 @@ toBaseComplex :: Complex -> C.Complex Double toBaseComplex (Complex d1# d2#) = (D# d1#) C.:+ (D# d2#) fromBaseComplex :: C.Complex Double -> Complex -fromBaseComplex ( (D# d1#) C.:+ (D# d2#) ) = Complex d1# d2# +fromBaseComplex ((D# d1#) C.:+ (D# d2#)) = Complex d1# d2# instance Eq Complex where Complex a b == Complex c d = case a ==## c of 1# -> case b ==## d of 1# -> True - _ -> False - _ -> False + _ -> False + _ -> False instance Show Complex where - showsPrec p (Complex a b) - = showParen (p >= 11) - $ showString "Complex " + showsPrec p (Complex a b) = + showParen (p >= 11) $ + showString "Complex " . showsPrec 11 (D# a) . showString " " . showsPrec 11 (D# b) @@ -73,30 +66,33 @@ data Maybe = Maybe (# (# #) | Complex #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | c #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 c + (# | c #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 c instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Complex] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Complex] maybeToList = maybe [] (: []) @@ -108,13 +104,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Complex] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -148,4 +145,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Complex -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs b/src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs index 6994487..6fcad57 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Complex/Float.hs @@ -1,20 +1,14 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Complex.Float - ( Complex(..) + ( Complex (..) , toBaseComplex , fromBaseComplex - - , Maybe(..) + , Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -22,20 +16,19 @@ module Data.Maybe.Unpacked.Numeric.Complex.Float , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import qualified Data.Complex as C import GHC.Base (build) -import GHC.Exts (Float#,Float(F#),eqFloat#) +import GHC.Exts (Float (F#), Float#, eqFloat#) -import GHC.Read (Read(readPrec), expectP) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec), expectP) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P data Complex = Complex Float# Float# @@ -44,20 +37,20 @@ toBaseComplex :: Complex -> C.Complex Float toBaseComplex (Complex d1# d2#) = (F# d1#) C.:+ (F# d2#) fromBaseComplex :: C.Complex Float -> Complex -fromBaseComplex ( (F# d1#) C.:+ (F# d2#) ) = Complex d1# d2# +fromBaseComplex ((F# d1#) C.:+ (F# d2#)) = Complex d1# d2# instance Eq Complex where Complex a b == Complex c d = case a `eqFloat#` c of 1# -> case b `eqFloat#` d of 1# -> True - _ -> False - _ -> False + _ -> False + _ -> False instance Show Complex where - showsPrec p (Complex a b) - = showParen (p >= 11) - $ showString "Complex " + showsPrec p (Complex a b) = + showParen (p >= 11) $ + showString "Complex " . showsPrec 11 (F# a) . showString " " . showsPrec 11 (F# b) @@ -73,30 +66,33 @@ data Maybe = Maybe (# (# #) | Complex #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | c #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 c + (# | c #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 c instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Complex] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Complex] maybeToList = maybe [] (: []) @@ -108,13 +104,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Complex] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -148,4 +145,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Complex -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Double.hs b/src/Data/Maybe/Unpacked/Numeric/Double.hs index d36bfcd..01fbc87 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Double.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Double.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Double - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,52 +13,54 @@ module Data.Maybe.Unpacked.Numeric.Double , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) -import GHC.Exts (Double#,Double(D#)) +import GHC.Exts (Double (D#), Double#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P data Maybe = Maybe (# (# #) | Double# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | d #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (D# d) + (# | d #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (D# d) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Double] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Double] maybeToList = maybe [] (: []) @@ -75,13 +72,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Double] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} diff --git a/src/Data/Maybe/Unpacked/Numeric/Float.hs b/src/Data/Maybe/Unpacked/Numeric/Float.hs index bcc19be..f75e54c 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Float.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Float.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Float - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,52 +13,54 @@ module Data.Maybe.Unpacked.Numeric.Float , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) -import GHC.Exts (Float#,Float(F#)) +import GHC.Exts (Float (F#), Float#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P data Maybe = Maybe (# (# #) | Float# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | d #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (F# d) + (# | d #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (F# d) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Float] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Float] maybeToList = maybe [] (: []) @@ -75,13 +72,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Float] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} diff --git a/src/Data/Maybe/Unpacked/Numeric/Int.hs b/src/Data/Maybe/Unpacked/Numeric/Int.hs index dd2b87a..c767bec 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Int.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Int.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Int - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,20 +13,19 @@ module Data.Maybe.Unpacked.Numeric.Int , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Int#) -import GHC.Int (Int(I#)) +import GHC.Int (Int (I#)) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -39,33 +33,36 @@ data Maybe = Maybe (# (# #) | Int# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | i #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (I# i) + (# | i #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (I# i) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Int] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Int] maybeToList = maybe [] (: []) @@ -77,13 +74,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Int] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -117,4 +115,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Int -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Int16.hs b/src/Data/Maybe/Unpacked/Numeric/Int16.hs index 3751148..6d4f9b3 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Int16.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Int16.hs @@ -1,17 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedSums #-} -{-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Int16 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -19,21 +14,20 @@ module Data.Maybe.Unpacked.Numeric.Int16 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where - -import Prelude hiding (Maybe,maybe) + ) where + +import Prelude hiding (Maybe, maybe) import GHC.Base (build) -import GHC.Exts (Int#, (>#), (<#)) +import GHC.Exts (Int#, (<#), (>#)) import GHC.Int (Int16) import GHC.Int.Compat (pattern I16#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -41,35 +35,40 @@ data Maybe = M Int# instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p m = - maybe (showString "nothing") - (\i -> showParen (p > 10) - $ showString "just " - . showsPrec 11 i - ) m + maybe + (showString "nothing") + ( \i -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 i + ) + m instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Int16] -> Maybe {-# INLINE listToMaybe #-} listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Int16] maybeToList m = maybe [] (: []) m @@ -81,13 +80,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Int16] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -118,9 +118,9 @@ maybe :: a -> (Int16 -> a) -> Maybe -> a {-# INLINE maybe #-} maybe a f (M m) = case m ># 32767# of 1# -> a - _ -> case m <# -32768# of + _ -> case m <# -32768# of 1# -> a - _ -> f (I16# m) + _ -> f (I16# m) toBaseMaybe :: Maybe -> P.Maybe Int16 {-# INLINE toBaseMaybe #-} @@ -129,4 +129,3 @@ toBaseMaybe m = maybe P.Nothing P.Just m fromBaseMaybe :: P.Maybe Int16 -> Maybe {-# INLINE fromBaseMaybe #-} fromBaseMaybe m = P.maybe nothing just m - diff --git a/src/Data/Maybe/Unpacked/Numeric/Int32.hs b/src/Data/Maybe/Unpacked/Numeric/Int32.hs index deb54fe..0afc3dc 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Int32.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Int32.hs @@ -1,17 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedSums #-} -{-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Int32 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -19,20 +14,19 @@ module Data.Maybe.Unpacked.Numeric.Int32 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where - -import Prelude hiding (Maybe,maybe) + ) where -import GHC.Exts +import Prelude hiding (Maybe, maybe) + +import GHC.Exts import GHC.Int (Int32) import GHC.Int.Compat (pattern I32#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -40,37 +34,42 @@ data Maybe = M Int# instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma {-# INLINE (==) #-} instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma {-# INLINE compare #-} instance Show Maybe where showsPrec p m = - maybe (showString "nothing") - (\i -> showParen (p > 10) - $ showString "just " - . showsPrec 11 i - ) m + maybe + (showString "nothing") + ( \i -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 i + ) + m instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Int32] -> Maybe {-# INLINE listToMaybe #-} listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Int32] maybeToList m = maybe [] (: []) m @@ -82,13 +81,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Int32] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -119,9 +119,9 @@ maybe :: a -> (Int32 -> a) -> Maybe -> a {-# INLINE maybe #-} maybe a f (M m) = case m ># 2147483647# of 1# -> a - _ -> case m <# -2147483648# of + _ -> case m <# -2147483648# of 1# -> a - _ -> f (I32# m) + _ -> f (I32# m) toBaseMaybe :: Maybe -> P.Maybe Int32 {-# INLINE toBaseMaybe #-} @@ -130,4 +130,3 @@ toBaseMaybe m = maybe P.Nothing P.Just m fromBaseMaybe :: P.Maybe Int32 -> Maybe {-# INLINE fromBaseMaybe #-} fromBaseMaybe m = P.maybe nothing just m - diff --git a/src/Data/Maybe/Unpacked/Numeric/Int64.hs b/src/Data/Maybe/Unpacked/Numeric/Int64.hs index 61e276a..b0da53b 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Int64.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Int64.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Int64 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,20 +13,19 @@ module Data.Maybe.Unpacked.Numeric.Int64 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Int64#) -import GHC.Int (Int64(I64#)) +import GHC.Int (Int64 (I64#)) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -39,33 +33,36 @@ data Maybe = Maybe (# (# #) | Int64# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | i #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (I64# i) + (# | i #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (I64# i) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Int64] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Int64] maybeToList = maybe [] (: []) @@ -77,13 +74,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Int64] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -117,4 +115,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Int64 -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Int8.hs b/src/Data/Maybe/Unpacked/Numeric/Int8.hs index e68cdbe..394aa1f 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Int8.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Int8.hs @@ -1,17 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedSums #-} -{-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Int8 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -19,20 +14,19 @@ module Data.Maybe.Unpacked.Numeric.Int8 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) -import GHC.Exts +import GHC.Exts import GHC.Int (Int8) import GHC.Int.Compat (pattern I8#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -40,35 +34,40 @@ data Maybe = M Int# instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p m = - maybe (showString "nothing") - (\i -> showParen (p > 10) - $ showString "just " - . showsPrec 11 i - ) m + maybe + (showString "nothing") + ( \i -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 i + ) + m instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Int8] -> Maybe {-# INLINE listToMaybe #-} listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Int8] maybeToList m = maybe [] (: []) m @@ -80,13 +79,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Int8] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -117,9 +117,9 @@ maybe :: a -> (Int8 -> a) -> Maybe -> a {-# INLINE maybe #-} maybe a f (M m) = case m ># 127# of 1# -> a - _ -> case m <# -128# of + _ -> case m <# -128# of 1# -> a - _ -> f (I8# m) + _ -> f (I8# m) toBaseMaybe :: Maybe -> P.Maybe Int8 {-# INLINE toBaseMaybe #-} @@ -128,4 +128,3 @@ toBaseMaybe m = maybe P.Nothing P.Just m fromBaseMaybe :: P.Maybe Int8 -> Maybe {-# INLINE fromBaseMaybe #-} fromBaseMaybe m = P.maybe nothing just m - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word.hs b/src/Data/Maybe/Unpacked/Numeric/Word.hs index 8130a38..c88ee76 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Word - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,20 +13,19 @@ module Data.Maybe.Unpacked.Numeric.Word , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where - -import Prelude hiding (Maybe,maybe) + ) where + +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Word#) -import GHC.Word (Word(W#)) +import GHC.Word (Word (W#)) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -39,33 +33,36 @@ data Maybe = Maybe (# (# #) | Word# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | w #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (W# w) + (# | w #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (W# w) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word] maybeToList = maybe [] (: []) @@ -77,13 +74,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -117,4 +115,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word128.hs b/src/Data/Maybe/Unpacked/Numeric/Word128.hs index 77a40cb..76dd148 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word128.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word128.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Word128 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,21 +13,20 @@ module Data.Maybe.Unpacked.Numeric.Word128 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) -import Data.WideWord (Word128(..)) +import Data.WideWord (Word128 (..)) import GHC.Base (build) import GHC.Exts (Word64#) -import GHC.Word (Word64(W64#)) +import GHC.Word (Word64 (W64#)) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -40,33 +34,36 @@ data Maybe = Maybe (# (# #) | (# Word64#, Word64# #) #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | (# wa, wb #) #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (Word128 (W64# wa) (W64# wb)) + (# | (# wa, wb #) #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (Word128 (W64# wa) (W64# wb)) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = prec 10 $ do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = prec 10 $ do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word128] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word128] maybeToList = maybe [] (: []) @@ -78,13 +75,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word128] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -118,5 +116,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word128 -> Maybe fromBaseMaybe = P.maybe nothing just - - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word16.hs b/src/Data/Maybe/Unpacked/Numeric/Word16.hs index 3ebd894..940ac1b 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word16.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word16.hs @@ -1,17 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Word16 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -19,21 +14,20 @@ module Data.Maybe.Unpacked.Numeric.Word16 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Word#) import GHC.Word (Word16) import GHC.Word.Compat (pattern W16#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -41,33 +35,36 @@ data Maybe = Maybe (# (# #) | Word# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | w #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (W16# w) + (# | w #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (W16# w) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word16] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word16] maybeToList = maybe [] (: []) @@ -79,13 +76,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word16] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -119,4 +117,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word16 -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word32.hs b/src/Data/Maybe/Unpacked/Numeric/Word32.hs index 2ab39d5..46e7915 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word32.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word32.hs @@ -1,18 +1,13 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE ViewPatterns #-} module Data.Maybe.Unpacked.Numeric.Word32 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -20,25 +15,24 @@ module Data.Maybe.Unpacked.Numeric.Word32 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe -- * Patterns , pattern Nothing , pattern Just - ) where + ) where -import Prelude hiding (Maybe,Nothing,Just,maybe) +import Prelude hiding (Just, Maybe, Nothing, maybe) import GHC.Base (build) import GHC.Exts (Word#) import GHC.Word (Word32) import GHC.Word.Compat (pattern W32#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -49,39 +43,43 @@ pattern Nothing = Maybe (# (# #) | #) pattern Just :: Word32 -> Maybe pattern Just i <- Maybe (# | (W32# -> i) #) - where Just (W32# i) = Maybe (# | i #) + where + Just (W32# i) = Maybe (# | i #) {-# COMPLETE Nothing, Just #-} instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | w #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (W32# w) + (# | w #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (W32# w) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word32] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word32] maybeToList = maybe [] (: []) @@ -93,13 +91,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word32] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -133,4 +132,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word32 -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word64.hs b/src/Data/Maybe/Unpacked/Numeric/Word64.hs index 8d6c72a..ca08b45 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word64.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word64.hs @@ -1,16 +1,11 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Word64 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -18,20 +13,19 @@ module Data.Maybe.Unpacked.Numeric.Word64 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Word64#) -import GHC.Word (Word64(W64#)) +import GHC.Word (Word64 (W64#)) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -39,33 +33,36 @@ data Maybe = Maybe (# (# #) | Word64# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | w #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (W64# w) + (# | w #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (W64# w) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word64] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word64] maybeToList = maybe [] (: []) @@ -77,13 +74,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word64] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -117,4 +115,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word64 -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/src/Data/Maybe/Unpacked/Numeric/Word8.hs b/src/Data/Maybe/Unpacked/Numeric/Word8.hs index e11479d..902ebed 100644 --- a/src/Data/Maybe/Unpacked/Numeric/Word8.hs +++ b/src/Data/Maybe/Unpacked/Numeric/Word8.hs @@ -1,17 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} module Data.Maybe.Unpacked.Numeric.Word8 - ( Maybe(..) + ( Maybe (..) , just , nothing - , maybe - , isJust , isNothing , fromMaybe @@ -19,21 +14,20 @@ module Data.Maybe.Unpacked.Numeric.Word8 , maybeToList , catMaybes , mapMaybe - , toBaseMaybe , fromBaseMaybe - ) where + ) where -import Prelude hiding (Maybe,maybe) +import Prelude hiding (Maybe, maybe) import GHC.Base (build) import GHC.Exts (Word#) import GHC.Word (Word8) import GHC.Word.Compat (pattern W8#) -import GHC.Read (Read(readPrec)) -import Text.Read (parens, Lexeme(Ident), lexP, (+++)) +import GHC.Read (Read (readPrec)) import Text.ParserCombinators.ReadPrec (prec, step) +import Text.Read (Lexeme (Ident), lexP, parens, (+++)) import qualified Prelude as P @@ -41,33 +35,36 @@ data Maybe = Maybe (# (# #) | Word# #) instance Eq Maybe where ma == mb = - maybe (isNothing mb) - (\a -> maybe False (\b -> a == b) mb) ma - + maybe + (isNothing mb) + (\a -> maybe False (\b -> a == b) mb) + ma + instance Ord Maybe where - compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma + compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma instance Show Maybe where showsPrec p (Maybe m) = case m of (# (# #) | #) -> showString "nothing" - (# | w #) -> showParen (p > 10) - $ showString "just " - . showsPrec 11 (W8# w) + (# | w #) -> + showParen (p > 10) $ + showString "just " + . showsPrec 11 (W8# w) instance Read Maybe where readPrec = parens $ nothingP +++ justP - where - nothingP = do - Ident "nothing" <- lexP - return nothing - justP = prec 10 $ do - Ident "just" <- lexP - a <- step readPrec - return (just a) + where + nothingP = do + Ident "nothing" <- lexP + return nothing + justP = prec 10 $ do + Ident "just" <- lexP + a <- step readPrec + return (just a) listToMaybe :: [Word8] -> Maybe listToMaybe [] = nothing -listToMaybe (x:_) = just x +listToMaybe (x : _) = just x maybeToList :: Maybe -> [Word8] maybeToList = maybe [] (: []) @@ -79,13 +76,14 @@ mapMaybe :: (a -> Maybe) -> [a] -> [Word8] mapMaybe _ [] = [] mapMaybe f (a : as) = let ws = mapMaybe f as - in maybe ws (: ws) (f a) + in maybe ws (: ws) (f a) {-# NOINLINE [1] mapMaybe #-} {-# RULES -"mapMaybe" [~1] forall f xs. mapMaybe f xs - = build (\c n -> foldr (mapMaybeFB c f) n xs) -"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f +"mapMaybe" [~1] forall f xs. + mapMaybe f xs = + build (\c n -> foldr (mapMaybeFB c f) n xs) +"mapMaybeList" [1] forall f. foldr (mapMaybeFB (:) f) [] = mapMaybe f #-} {-# NOINLINE [0] mapMaybeFB #-} @@ -119,4 +117,3 @@ toBaseMaybe = maybe P.Nothing P.Just fromBaseMaybe :: P.Maybe Word8 -> Maybe fromBaseMaybe = P.maybe nothing just - diff --git a/test/laws.hs b/test/laws.hs index 3c785f7..951767f 100644 --- a/test/laws.hs +++ b/test/laws.hs @@ -1,29 +1,29 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -Wno-orphans #-} -import Test.QuickCheck.Arbitrary -import Test.QuickCheck.Gen -import Test.QuickCheck.Classes import Data.Proxy (Proxy (Proxy)) import GHC.Exts +import Test.QuickCheck.Arbitrary +import Test.QuickCheck.Classes +import Test.QuickCheck.Gen -import qualified Data.Maybe.Unpacked.Numeric.Complex.Float as MComplexFloat import qualified Data.Maybe.Unpacked.Numeric.Complex.Double as MComplexDouble +import qualified Data.Maybe.Unpacked.Numeric.Complex.Float as MComplexFloat -import qualified Data.Maybe.Unpacked.Numeric.Float as MFloat import qualified Data.Maybe.Unpacked.Numeric.Double as MDouble +import qualified Data.Maybe.Unpacked.Numeric.Float as MFloat -import qualified Data.Maybe.Unpacked.Numeric.Int as MInt -import qualified Data.Maybe.Unpacked.Numeric.Int8 as MInt8 -import qualified Data.Maybe.Unpacked.Numeric.Int16 as MInt16 -import qualified Data.Maybe.Unpacked.Numeric.Int32 as MInt32 -import qualified Data.Maybe.Unpacked.Numeric.Int64 as MInt64 +import qualified Data.Maybe.Unpacked.Numeric.Int as MInt +import qualified Data.Maybe.Unpacked.Numeric.Int16 as MInt16 +import qualified Data.Maybe.Unpacked.Numeric.Int32 as MInt32 +import qualified Data.Maybe.Unpacked.Numeric.Int64 as MInt64 +import qualified Data.Maybe.Unpacked.Numeric.Int8 as MInt8 -import qualified Data.Maybe.Unpacked.Numeric.Word as MWord -import qualified Data.Maybe.Unpacked.Numeric.Word8 as MWord8 +import qualified Data.Maybe.Unpacked.Numeric.Word as MWord import qualified Data.Maybe.Unpacked.Numeric.Word16 as MWord16 import qualified Data.Maybe.Unpacked.Numeric.Word32 as MWord32 import qualified Data.Maybe.Unpacked.Numeric.Word64 as MWord64 +import qualified Data.Maybe.Unpacked.Numeric.Word8 as MWord8 main :: IO () main = lawsCheckMany allPropsApplied @@ -34,17 +34,21 @@ allLaws :: , Ord a , Show a , Read a - ) => Proxy a -> [Laws] -allLaws p = map ($ p) - [ eqLaws, ordLaws, showReadLaws - ] - + ) => + Proxy a -> + [Laws] +allLaws p = + map + ($ p) + [ eqLaws + , ordLaws + , showReadLaws + ] allPropsApplied :: [(String, [Laws])] allPropsApplied = [ ("Maybe (Complex Float)", map ($ (Proxy :: Proxy MComplexFloat.Maybe)) [eqLaws, showReadLaws]) , ("Maybe (Complex Double)", map ($ (Proxy :: Proxy MComplexDouble.Maybe)) [eqLaws, showReadLaws]) - , ("Maybe Float", allLaws (Proxy :: Proxy MFloat.Maybe)) , ("Maybe Double", allLaws (Proxy :: Proxy MDouble.Maybe)) , ("Maybe Int8", allLaws (Proxy :: Proxy MInt8.Maybe)) @@ -78,16 +82,16 @@ instance Arbitrary MComplexDouble.Complex where pure (MComplexDouble.Complex (unDouble x) (unDouble y)) instance Arbitrary MComplexFloat.Maybe where - arbitrary = frequency [(1,pure MComplexFloat.nothing), (1, MComplexFloat.just <$> arbitrary)] + arbitrary = frequency [(1, pure MComplexFloat.nothing), (1, MComplexFloat.just <$> arbitrary)] instance Arbitrary MComplexDouble.Maybe where - arbitrary = frequency [(1,pure MComplexDouble.nothing), (1, MComplexDouble.just <$> arbitrary)] + arbitrary = frequency [(1, pure MComplexDouble.nothing), (1, MComplexDouble.just <$> arbitrary)] instance Arbitrary MFloat.Maybe where - arbitrary = frequency [(1,pure MFloat.nothing), (1, MFloat.just <$> arbitrary)] + arbitrary = frequency [(1, pure MFloat.nothing), (1, MFloat.just <$> arbitrary)] instance Arbitrary MDouble.Maybe where - arbitrary = frequency [(1,pure MDouble.nothing), (1, MDouble.just <$> arbitrary)] + arbitrary = frequency [(1, pure MDouble.nothing), (1, MDouble.just <$> arbitrary)] instance Arbitrary MWord8.Maybe where arbitrary = frequency [(1, pure MWord8.nothing), (1, MWord8.just <$> arbitrary)] @@ -117,4 +121,4 @@ instance Arbitrary MInt64.Maybe where arbitrary = frequency [(1, pure MInt64.nothing), (1, MInt64.just <$> arbitrary)] instance Arbitrary MInt.Maybe where - arbitrary = frequency [(1, pure MInt.nothing), (1, MInt.just <$> arbitrary)] \ No newline at end of file + arbitrary = frequency [(1, pure MInt.nothing), (1, MInt.just <$> arbitrary)] diff --git a/unpacked-maybe-numeric.cabal b/unpacked-maybe-numeric.cabal index 9bc0961..d1e8806 100644 --- a/unpacked-maybe-numeric.cabal +++ b/unpacked-maybe-numeric.cabal @@ -1,7 +1,7 @@ -cabal-version: 2.2 -name: unpacked-maybe-numeric -version: 0.1.3.0 -synopsis: maybes of numeric values with fewer indirections +cabal-version: 2.2 +name: unpacked-maybe-numeric +version: 0.1.3.0 +synopsis: maybes of numeric values with fewer indirections description: This library provides one `Maybe` type per the usual numeric types: Float, Double, Complex {Float|Double}, Int{8|16|32|64}, and Word{8|16|32|64|128} @@ -11,65 +11,68 @@ description: the `Maybe` is just a wrapper around the underlying type, with out-of-bounds corresponding to the `Nothing` value. Thus, the use of these constructors is unsafe, as this is only checked internally. -homepage: https://github.com/andrewthad/unpacked-maybe-numeric#readme -bug-reports: https://github.com/andrewthad/unpacked-maybe-numeric/issues -author: Andrew Martin, chessai -maintainer: andrew.thaddeus@gmail.com, chessai1996@gmail.com -category: Data -copyright: 2018 Andrew Martin -license: BSD-3-Clause -license-file: LICENSE -build-type: Simple -extra-source-files: README.md -source-repository head - type: git - location: https://github.com/andrewthad/unpacked-maybe-numeric +homepage: https://github.com/andrewthad/unpacked-maybe-numeric#readme +bug-reports: https://github.com/andrewthad/unpacked-maybe-numeric/issues +author: Andrew Martin, chessai +maintainer: andrew.thaddeus@gmail.com, chessai1996@gmail.com +category: Data +copyright: 2018 Andrew Martin +license: BSD-3-Clause +license-file: LICENSE +build-type: Simple +extra-source-files: README.md library exposed-modules: - Data.Maybe.Unpacked.Numeric.Complex.Float Data.Maybe.Unpacked.Numeric.Complex.Double - Data.Maybe.Unpacked.Numeric.Float + Data.Maybe.Unpacked.Numeric.Complex.Float Data.Maybe.Unpacked.Numeric.Double + Data.Maybe.Unpacked.Numeric.Float Data.Maybe.Unpacked.Numeric.Int - Data.Maybe.Unpacked.Numeric.Int8 Data.Maybe.Unpacked.Numeric.Int16 Data.Maybe.Unpacked.Numeric.Int32 Data.Maybe.Unpacked.Numeric.Int64 + Data.Maybe.Unpacked.Numeric.Int8 Data.Maybe.Unpacked.Numeric.Word - Data.Maybe.Unpacked.Numeric.Word8 + Data.Maybe.Unpacked.Numeric.Word128 Data.Maybe.Unpacked.Numeric.Word16 Data.Maybe.Unpacked.Numeric.Word32 Data.Maybe.Unpacked.Numeric.Word64 - Data.Maybe.Unpacked.Numeric.Word128 - hs-source-dirs: src + Data.Maybe.Unpacked.Numeric.Word8 + + hs-source-dirs: src build-depends: - , base >=4.17.1.0 && <5 - , primitive >= 0.6.4 - , wide-word >= 0.1.0.8 && < 0.2 - , word-compat >= 0.0.4 && <0.1 - ghc-options: -Wall -O2 + , base >=4.17.1.0 && <5 + , primitive >=0.6.4 + , wide-word >=0.1.0.8 && <0.2 + , word-compat >=0.0.4 && <0.1 + + 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 + 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 - ghc-options: -Wall - type: exitcode-stdio-1.0 - main-is: laws.hs - hs-source-dirs: test + ghc-options: -Wall + type: exitcode-stdio-1.0 + main-is: laws.hs + hs-source-dirs: test build-depends: - , QuickCheck , base + , QuickCheck , quickcheck-classes , unpacked-maybe-numeric + +source-repository head + type: git + location: https://github.com/andrewthad/unpacked-maybe-numeric