Skip to content

Commit

Permalink
semigroup and monoid instance for bottom and top (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
noinia authored Sep 8, 2024
1 parent a8c2017 commit 8089184
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hgeometry-combinatorial/src/HGeometry/Unbounded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import qualified Data.Traversable as T
-- >>> data Top a = ValT a | Top
newtype Top a = GTop (Maybe a)
deriving (Eq,Functor,F.Foldable,T.Traversable,Applicative,Monad,Eq1)
deriving newtype (Semigroup,Monoid)

-- | @Top a@ values are isomorphing to @Maybe a@ values.
topToMaybe :: Top a -> Maybe a
Expand All @@ -51,6 +52,8 @@ pattern Top = GTop Nothing
{-# COMPLETE ValT, Top #-}




instance Ord1 Top where
liftCompare _ Top Top = EQ
liftCompare _ _ Top = LT
Expand Down Expand Up @@ -102,6 +105,7 @@ _TopMaybe = iso topToMaybe GTop
-- >>> data Bottom a = Bottom | ValB a
newtype Bottom a = GBottom (Maybe a)
deriving (Eq,Ord,Functor,F.Foldable,T.Traversable,Applicative,Monad,Eq1,Ord1)
deriving newtype (Semigroup,Monoid)

-- | `Bottom a` values are isomorphing to `Maybe a` values.
bottomToMaybe :: Bottom a -> Maybe a
Expand Down

0 comments on commit 8089184

Please sign in to comment.