Created
April 7, 2019 23:12
-
-
Save vieiralucas/de8d21ac191a2210ffd82f1f23ae7f12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Option, none, some } from 'fp-ts/lib/Option' | |
| import { TaskEither, fromLeft, taskEither } from 'fp-ts/lib/TaskEither' | |
| const a = (): Option<number> => { | |
| if (Math.random() > 0.5) { | |
| return none | |
| } | |
| return some(1) | |
| } | |
| const b = (): Option<TaskEither<Error, number>> => { | |
| return a().map(n => { | |
| if (Math.random() > 0.5) { | |
| return fromLeft(new Error('very unlucky')) | |
| } | |
| return taskEither.of(n) | |
| }) | |
| } | |
| const c = (): TaskEither<Error, Option<TaskEither<Error, number>>> => { | |
| if (Math.random() > 0.5) { | |
| return fromLeft(new Error('unlucky')) | |
| } | |
| return taskEither.of(b()) | |
| } | |
| const x: TaskEither<Error, Option<TaskEither<Error, number>>> = c() | |
| // how to get to this type from x? | |
| const y: TaskEither<Error, Option<number>> = ??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment