Skip to content

Commit

Permalink
fixed OptionT to only run code on none once
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Sep 4, 2017
1 parent c8cb5a3 commit 4f8cf76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- **Bug Fix**
- fixed EitherT to only run code on the left once, closes #219 (@nfma)
- fixed OptionT to only run code on none once (@gcanti)

# 0.5.1

Expand Down
11 changes: 5 additions & 6 deletions src/OptionT.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HKT, HKTS, HKT2S, HKTAs, HKT2As } from './HKT'
import { Functor } from './Functor'
import { Monad } from './Monad'
import { Chain } from './Chain'
import {
Applicative,
getApplicativeComposition,
Expand All @@ -26,11 +25,11 @@ export interface OptionT2<M extends HKT2S> extends ApplicativeComposition21<M, O
}

export class Ops {
chain<F extends HKT2S>(F: Chain<F>): OptionT2<F>['chain']
chain<F extends HKTS>(F: Chain<F>): OptionT1<F>['chain']
chain<F>(F: Chain<F>): OptionT<F>['chain']
chain<F>(F: Chain<F>): OptionT<F>['chain'] {
return (f, fa) => F.chain(o => o.fold(() => fa as any, a => f(a)), fa)
chain<F extends HKT2S>(F: Monad<F>): OptionT2<F>['chain']
chain<F extends HKTS>(F: Monad<F>): OptionT1<F>['chain']
chain<F>(F: Monad<F>): OptionT<F>['chain']
chain<F>(F: Monad<F>): OptionT<F>['chain'] {
return (f, fa) => F.chain(o => o.fold(() => F.of(option.none), a => f(a)), fa)
}

some<F extends HKT2S>(F: Applicative<F>): <L, A>(a: A) => HKT2As<F, L, Option<A>>
Expand Down

0 comments on commit 4f8cf76

Please sign in to comment.