File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
7
7
Breaking changes:
8
8
9
9
New features:
10
+ - Added ` Semiring ` instance (#59 )
10
11
11
12
Bugfixes:
12
13
Original file line number Diff line number Diff line change @@ -190,6 +190,16 @@ instance semigroupMaybe :: Semigroup a => Semigroup (Maybe a) where
190
190
instance monoidMaybe :: Semigroup a => Monoid (Maybe a ) where
191
191
mempty = Nothing
192
192
193
+ instance semiringMaybe :: Semiring a => Semiring (Maybe a ) where
194
+ zero = Nothing
195
+ one = Just one
196
+
197
+ add Nothing y = y
198
+ add x Nothing = x
199
+ add (Just x) (Just y) = Just (add x y)
200
+
201
+ mul x y = mul <$> x <*> y
202
+
193
203
-- | The `Eq` instance allows `Maybe` values to be checked for equality with
194
204
-- | `==` and inequality with `/=` whenever there is an `Eq` instance for the
195
205
-- | type the `Maybe` contains.
You can’t perform that action at this time.
0 commit comments