Skip to content

Commit

Permalink
feat(fio): add FIO.ap static function
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Jul 21, 2019
1 parent 766e356 commit 949360b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/FIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ export class FIO<E1 = unknown, A1 = unknown, R1 = NoEnv> {
return new FIO(Tag.Access, cb)
}

/**
* Converts a [[FIO]] of a function into a [[FIO]] of a value.
*/
public static ap<E1, A1, R1, A2>(
fio: FIO<E1, (a: A1) => A2, R1>,
input: A1
): FIO<E1, A2, R1> {
return fio.map(ab => ab(input))
}

/**
* **NOTE:** The default type is set to `never` because it hard for typescript to infer the types based on how we use `res`.
* Using `never` will give users compile time error always while using.
Expand Down

0 comments on commit 949360b

Please sign in to comment.