@@ -251,15 +251,19 @@ isLeft = either (const true) (const false)
251
251
isRight :: forall a b . Either a b -> Boolean
252
252
isRight = either (const false ) (const true )
253
253
254
- -- | A partial function that extracts the value from the `Left` data constructor.
255
- -- | Passing a `Right` to `fromLeft` will throw an error at runtime.
256
- fromLeft :: forall a b . Partial => Either a b -> a
257
- fromLeft (Left a) = a
258
-
259
- -- | A partial function that extracts the value from the `Right` data constructor.
260
- -- | Passing a `Left` to `fromRight` will throw an error at runtime.
261
- fromRight :: forall a b . Partial => Either a b -> b
262
- fromRight (Right a) = a
254
+ -- | A function that extracts the value from the `Left` data constructor.
255
+ -- | The first argument is a default value, which will be returned in the
256
+ -- | case where a `Right` is passed to `fromLeft`.
257
+ fromLeft :: forall a b . a -> Either a b -> a
258
+ fromLeft _ (Left a) = a
259
+ fromLeft default _ = default
260
+
261
+ -- | A function that extracts the value from the `Right` data constructor.
262
+ -- | The first argument is a default value, which will be returned in the
263
+ -- | case where a `Left` is passed to `fromRight`.
264
+ fromRight :: forall a b . b -> Either a b -> b
265
+ fromRight _ (Right b) = b
266
+ fromRight default _ = default
263
267
264
268
-- | Takes a default and a `Maybe` value, if the value is a `Just`, turn it into
265
269
-- | a `Right`, if the value is a `Nothing` use the provided default as a `Left`
0 commit comments