Skip to content

Commit

Permalink
Prepare 0.1.3.1 release.
Browse files Browse the repository at this point in the history
Removed upper bound on dependency.
Fix all Ord instances
Use new .github workflows.

Co-authored-by: Andrew Martin <[email protected]>
  • Loading branch information
brianjosephmckeon and andrewthad authored Feb 14, 2024
1 parent 3682aad commit 9f1f104
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 53 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/build.yaml@main
secrets: inherit
uses: byteverse/.github/.github/workflows/build-matrix.yaml@main
with:
release: false
cabal-file: unpacked-maybe-numeric.cabal
4 changes: 1 addition & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ on:

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/build.yaml@main
uses: byteverse/.github/.github/workflows/release.yaml@main
secrets: inherit
with:
release: true
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for unpacked-maybe-numeric

## 0.1.3.1 -- 2024-02-14

* Update package metadata.
* Fix failing test suite.

## 0.1.1.0 -- 2019-09-28

* Add module for `Word128`-variant of `Maybe`.
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: .
tests: True
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Double.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (D# a) (D# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Float.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (F# a) (F# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Int.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (I# a) (I# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
29 changes: 27 additions & 2 deletions src/Data/Maybe/Unpacked/Numeric/Int16.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE UnboxedSums #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ViewPatterns #-}

module Data.Maybe.Unpacked.Numeric.Int16
( Maybe (..)
Expand All @@ -16,9 +18,12 @@ module Data.Maybe.Unpacked.Numeric.Int16
, mapMaybe
, toBaseMaybe
, fromBaseMaybe
-- * Patterns
, pattern Nothing
, pattern Just
) where

import Prelude hiding (Maybe, maybe)
import Prelude hiding (Just, Maybe, Nothing, maybe)

import GHC.Base (build)
import GHC.Exts (Int#, (<#), (>#))
Expand All @@ -41,7 +46,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare ma mb = case ma of
Just a -> case mb of
Just b -> compare a b
_ -> GT
_ -> case mb of
Just{} -> LT
_ -> EQ

instance Show Maybe where
showsPrec p m =
Expand Down Expand Up @@ -129,3 +140,17 @@ toBaseMaybe m = maybe P.Nothing P.Just m
fromBaseMaybe :: P.Maybe Int16 -> Maybe
{-# INLINE fromBaseMaybe #-}
fromBaseMaybe m = P.maybe nothing just m

pattern Nothing :: Maybe
pattern Nothing = M 32768#

pattern Just :: Int16 -> Maybe
pattern Just i <- (maybeInt16ToInt16 -> (# | i #))
where
Just (I16# i) = M i

maybeInt16ToInt16 :: Maybe -> (# (# #) | Int16 #)
{-# inline maybeInt16ToInt16 #-}
maybeInt16ToInt16 (M i) = case i of
32768# -> (# (# #) | #)
_ -> (# | I16# i #)
30 changes: 27 additions & 3 deletions src/Data/Maybe/Unpacked/Numeric/Int32.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE UnboxedSums #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ViewPatterns #-}

module Data.Maybe.Unpacked.Numeric.Int32
( Maybe (..)
Expand All @@ -16,9 +18,12 @@ module Data.Maybe.Unpacked.Numeric.Int32
, mapMaybe
, toBaseMaybe
, fromBaseMaybe
-- * Patterns
, pattern Nothing
, pattern Just
) where

import Prelude hiding (Maybe, maybe)
import Prelude hiding (Just, Maybe, Nothing, maybe)

import GHC.Exts
import GHC.Int (Int32)
Expand All @@ -41,8 +46,13 @@ instance Eq Maybe where
{-# INLINE (==) #-}

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
{-# INLINE compare #-}
compare ma mb = case ma of
Just a -> case mb of
Just b -> compare a b
_ -> GT
_ -> case mb of
Just{} -> LT
_ -> EQ

instance Show Maybe where
showsPrec p m =
Expand Down Expand Up @@ -130,3 +140,17 @@ toBaseMaybe m = maybe P.Nothing P.Just m
fromBaseMaybe :: P.Maybe Int32 -> Maybe
{-# INLINE fromBaseMaybe #-}
fromBaseMaybe m = P.maybe nothing just m

pattern Nothing :: Maybe
pattern Nothing = M 2147483648#

pattern Just :: Int32 -> Maybe
pattern Just i <- (maybeInt32ToInt32 -> (# | i #))
where
Just (I32# i) = M i

maybeInt32ToInt32 :: Maybe -> (# (# #) | Int32 #)
{-# inline maybeInt32ToInt32 #-}
maybeInt32ToInt32 (M i) = case i of
2147483648# -> (# (# #) | #)
_ -> (# | I32# i #)
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Int64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (I64# a) (I64# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
29 changes: 27 additions & 2 deletions src/Data/Maybe/Unpacked/Numeric/Int8.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE UnboxedSums #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ViewPatterns #-}

module Data.Maybe.Unpacked.Numeric.Int8
( Maybe (..)
Expand All @@ -16,9 +18,12 @@ module Data.Maybe.Unpacked.Numeric.Int8
, mapMaybe
, toBaseMaybe
, fromBaseMaybe
-- * Patterns
, pattern Nothing
, pattern Just
) where

import Prelude hiding (Maybe, maybe)
import Prelude hiding (Just, Maybe, Nothing, maybe)

import GHC.Exts
import GHC.Int (Int8)
Expand All @@ -40,7 +45,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare ma mb = case ma of
Just a -> case mb of
Just b -> compare a b
_ -> GT
_ -> case mb of
Just{} -> LT
_ -> EQ

instance Show Maybe where
showsPrec p m =
Expand Down Expand Up @@ -128,3 +139,17 @@ toBaseMaybe m = maybe P.Nothing P.Just m
fromBaseMaybe :: P.Maybe Int8 -> Maybe
{-# INLINE fromBaseMaybe #-}
fromBaseMaybe m = P.maybe nothing just m

pattern Nothing :: Maybe
pattern Nothing = M 128#

pattern Just :: Int8 -> Maybe
pattern Just i <- (maybeInt8ToInt8 -> (# | i #))
where
Just (I8# i) = M i

maybeInt8ToInt8 :: Maybe -> (# (# #) | Int8 #)
{-# inline maybeInt8ToInt8 #-}
maybeInt8ToInt8 (M i) = case i of
128# -> (# (# #) | #)
_ -> (# | I8# i #)
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Word.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (W# a) (W# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
24 changes: 22 additions & 2 deletions src/Data/Maybe/Unpacked/Numeric/Word16.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE ViewPatterns #-}

module Data.Maybe.Unpacked.Numeric.Word16
( Maybe (..)
Expand All @@ -16,9 +17,12 @@ module Data.Maybe.Unpacked.Numeric.Word16
, mapMaybe
, toBaseMaybe
, fromBaseMaybe
-- * Patterns
, pattern Nothing
, pattern Just
) where

import Prelude hiding (Maybe, maybe)
import Prelude hiding (Just, Maybe, Nothing, maybe)

import GHC.Base (build)
import GHC.Exts (Word#)
Expand All @@ -41,7 +45,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare ma mb = case ma of
Just a -> case mb of
Just b -> compare a b
_ -> GT
_ -> case mb of
Just{} -> LT
_ -> EQ

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down Expand Up @@ -117,3 +127,13 @@ toBaseMaybe = maybe P.Nothing P.Just

fromBaseMaybe :: P.Maybe Word16 -> Maybe
fromBaseMaybe = P.maybe nothing just

pattern Nothing :: Maybe
pattern Nothing = Maybe (# (# #) | #)

pattern Just :: Word16 -> Maybe
pattern Just i <- Maybe (# | (W16# -> i) #)
where
Just (W16# i) = Maybe (# | i #)

{-# COMPLETE Nothing, Just #-}
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Word32.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare ma mb = case ma of
Just a -> case mb of
Just b -> compare a b
_ -> GT
_ -> case mb of
Just{} -> LT
_ -> EQ

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
8 changes: 7 additions & 1 deletion src/Data/Maybe/Unpacked/Numeric/Word64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ instance Eq Maybe where
ma

instance Ord Maybe where
compare ma mb = maybe LT (\a -> maybe GT (compare a) mb) ma
compare (Maybe ma) (Maybe mb) = case ma of
(# (# #) | #) -> case mb of
(# (# #) | #) -> EQ
(# | _ #) -> LT
(# | a #) -> case mb of
(# (# #) | #) -> GT
(# | b #) -> compare (W64# a) (W64# b)

instance Show Maybe where
showsPrec p (Maybe m) = case m of
Expand Down
Loading

0 comments on commit 9f1f104

Please sign in to comment.