Skip to content

Commit

Permalink
These: add missing MonadThrow instance
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Feb 20, 2020
1 parent 74093f7 commit bd17f4b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
**Note**: Gaps between patch versions are faulty/broken releases. **Note**: A feature tagged as Experimental is in a
high state of flux, you're at risk of it changing without notice.

# 2.5.1

- **Polish**
- `These`
- add missing `MonadThrow` instance (@gcanti)

# 2.5.0

- **New Feature**
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/These.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Added in v2.0.0
**Signature**

```ts
export function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> { ... }
export function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadThrow2C<URI, E> { ... }
```

Added in v2.0.0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fp-ts",
"version": "2.5.0",
"version": "2.5.1",
"description": "Functional programming in TypeScript",
"files": [
"lib",
Expand Down
6 changes: 4 additions & 2 deletions src/These.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Foldable2 } from './Foldable'
import { Functor2 } from './Functor'
import { HKT } from './HKT'
import { Monad2C } from './Monad'
import { MonadThrow2C } from './MonadThrow'
import { isNone, none, Option, some } from './Option'
import { pipeable } from './pipeable'
import { Semigroup } from './Semigroup'
Expand Down Expand Up @@ -164,7 +165,7 @@ export function getSemigroup<E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigrou
/**
* @since 2.0.0
*/
export function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> {
export function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadThrow2C<URI, E> {
const chain = <A, B>(ma: These<E, A>, f: (a: A) => These<E, B>): These<E, B> => {
if (isLeft(ma)) {
return ma
Expand All @@ -186,7 +187,8 @@ export function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> {
map: these.map,
of: right,
ap: (mab, ma) => chain(mab, f => these.map(ma, f)),
chain
chain,
throwError: left
}
}

Expand Down

0 comments on commit bd17f4b

Please sign in to comment.