Skip to content

Commit b515c20

Browse files
Add blush as an analogue to hush (#69)
Also update docstring wording
1 parent 5fbe43c commit b515c20

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
77
Breaking changes:
88

99
New features:
10+
- Add `blush` which is a left-biased `hush`, thus turns `Right`s into `Nothing`s but `Left`s into `Just`s (#69).
1011

1112
Bugfixes:
1213

@@ -148,6 +149,3 @@ Add `Alt` instance
148149

149150

150151
## [v0.1.0](https://github.com/purescript/purescript-either/releases/tag/v0.1.0) - 2014-04-21
151-
152-
153-

src/Data/Either.purs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ note a = maybe (Left a) Right
273273
note' :: forall a b. (Unit -> a) -> Maybe b -> Either a b
274274
note' f = maybe' (Left <<< f) Right
275275

276-
-- | Turns an `Either` into a `Maybe`, by throwing eventual `Left` values away and converting
276+
-- | Turns an `Either` into a `Maybe`, by throwing potential `Left` values away and converting
277277
-- | them into `Nothing`. `Right` values get turned into `Just`s.
278278
-- |
279279
-- | ```purescript
@@ -282,3 +282,13 @@ note' f = maybe' (Left <<< f) Right
282282
-- | ```
283283
hush :: forall a b. Either a b -> Maybe b
284284
hush = either (const Nothing) Just
285+
286+
-- | Turns an `Either` into a `Maybe`, by throwing potential `Right` values away and converting
287+
-- | them into `Nothing`. `Left` values get turned into `Just`s.
288+
-- |
289+
-- | ```purescript
290+
-- | blush (Left "ParseError") = Just "Parse Error"
291+
-- | blush (Right 42) = Nothing
292+
-- | ```
293+
blush :: forall a b. Either a b -> Maybe a
294+
blush = either Just (const Nothing)

0 commit comments

Comments
 (0)