api/classes/qio
Globals / QIO
Class: QIO<A1, E1, R1>
Type parameters
| Name | Default | Description |
|---|---|---|
A1 | unknown | The output of the running the program successfully. |
E1 | never | Possible errors that could be thrown by the program. |
R1 | unknown | Environment needed to execute this instance. |
Hierarchy
- QIO
Index
Properties
Accessors
Methods
- addEnv
- and
- bracket
- bracket_
- catch
- chain
- const
- delay
- do
- encase
- encaseM
- fork
- forkWith
- map
- par
- provide
- provideM
- provideSome
- provideSomeM
- race
- raceWith
- rejectWith
- tap
- tapM
- zip
- zipWith
- zipWithM
- zipWithPar
- access
- accessA
- accessM
- accessP
- ap
- call
- chain
- encase
- encaseM
- encaseP
- env
- flatten
- fork
- fromEither
- fromExit
- if
- if0
- interruptible
- lazy
- lift
- map
- never
- par
- parN
- pipeEnv
- reject
- resolve
- runtime
- seq
- timeout
- try
- tryM
- tryP
- uninterruptible
- void
Properties
$R1
• Optional Readonly $R1: undefined | (r: R1) => void
Defined in packages/core/lib/main/QIO.ts:427
Hack: The property $R1 is added to enable stricter checks. More specifically enable contravariant check on R1.
Accessors
asEither
• get asEither(): QIO<Either<E1, A1>, never, R1>
Defined in packages/core/lib/main/QIO.ts:450
Safely converts an interuptable IO to non-interuptable one.
Returns: QIO<Either<E1, A1>, never, R1>
env
• get env(): QIO<R1, never, R1>
Defined in packages/core/lib/main/QIO.ts:463
Purely access the environment provided to the program.
Returns: QIO<R1, never, R1>
once
• get once(): QIO<QIO<A1, E1>, never, R1>
Defined in packages/core/lib/main/QIO.ts:470
Memorizes the result and executes the IO only once
Returns: QIO<QIO<A1, E1>, never, R1>
void
• get void(): QIO<void, E1, R1>
Defined in packages/core/lib/main/QIO.ts:478
Ignores the result of the c instance
Returns: QIO<void, E1, R1>
Methods
addEnv
▸ addEnv<R2>(): QIO<A1, E1, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:485
Gives access to additional env
Type parameters:
| Name |
|---|
R2 |
Returns: QIO<A1, E1, R1 & R2>
and
▸ and<A2, E2, R2>(aFb: QIO<A2, E2, R2>): QIO<A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:491
Runs the c instances one by one
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
aFb | QIO<A2, E2, R2> |
Returns: QIO<A2, E1 | E2, R1 & R2>
bracket
▸ bracket<E2, R2>(release: (A1: A1) => QIO<unknown, E2, R2>): function
Defined in packages/core/lib/main/QIO.ts:496
Type parameters:
| Name |
|---|
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
release | (A1: A1) => QIO<unknown, E2, R2> |
Returns: function
bracket_
▸ bracket_<E2, R2>(release: QIO<unknown, E2, R2>): function
Defined in packages/core/lib/main/QIO.ts:509
Type parameters:
| Name |
|---|
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
release | QIO<unknown, E2, R2> |
Returns: function
catch
▸ catch<A2, E2, R2>(aFb: (e: E1) => QIO<A2, E2, R2>): QIO<A1 | A2, E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:520
Captures the exception thrown by the IO and
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
aFb | (e: E1) => QIO<A2, E2, R2> |
Returns: QIO<A1 | A2, E2, R1 & R2>
chain
▸ chain<A2, E2, R2>(aFb: (a: A1) => QIO<A2, E2, R2>): QIO<A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:528
Chains one QIO after another.
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
aFb | (a: A1) => QIO<A2, E2, R2> |
Returns: QIO<A2, E1 | E2, R1 & R2>
const
▸ const<A2>(a: A2): QIO<A2, E1, R1>
Defined in packages/core/lib/main/QIO.ts:536
Ignores the original value of the c and resolves with the provided value
Type parameters:
| Name |
|---|
A2 |
Parameters:
| Name | Type |
|---|---|
a | A2 |
Returns: QIO<A2, E1, R1>
delay
▸ delay(duration: number): QIO<A1, E1, R1>
Defined in packages/core/lib/main/QIO.ts:542
Delays the execution of the QIO by the provided time.
Parameters:
| Name | Type |
|---|---|
duration | number |
Returns: QIO<A1, E1, R1>
do
▸ do<E2, R2>(io: QIO<unknown, E2, R2>): QIO<A1, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:548
Like QIO.tap but takes in an IO instead of a callback.
Type parameters:
| Name |
|---|
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
io | QIO<unknown, E2, R2> |
Returns: QIO<A1, E1 | E2, R1 & R2>
encase
▸ encase<A2, E2>(fn: (A1: A1) => A2): QIO<A2, E1 | E2, R1>
Defined in packages/core/lib/main/QIO.ts:555
Calls the effect-full function on success of the current c instance.
Type parameters:
| Name | Default |
|---|---|
A2 | unknown |
E2 | never |
Parameters:
| Name | Type |
|---|---|
fn | (A1: A1) => A2 |
Returns: QIO<A2, E1 | E2, R1>
encaseM
▸ encaseM<A2, E2, R2>(fn: (A1: A1) => QIO<A2, E2, R2>): QIO<A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:564
Calls the effect-full function returning a QIO on success of the current instance.
Type parameters:
| Name | Default |
|---|---|
A2 | unknown |
E2 | never |
R2 | unknown |
Parameters:
| Name | Type |
|---|---|
fn | (A1: A1) => QIO<A2, E2, R2> |
Returns: QIO<A2, E1 | E2, R1 & R2>
fork
▸ fork(config?: FiberConfig): QIO<Fiber<A1, E1>, never, R1>
Defined in packages/core/lib/main/QIO.ts:572
Returns a Fiber
Parameters:
| Name | Type |
|---|---|
config? | FiberConfig |
Returns: QIO<Fiber<A1, E1>, never, R1>
forkWith
▸ forkWith(runtime: IRuntime): QIO<Fiber<A1, E1>, never, R1>
Defined in packages/core/lib/main/QIO.ts:583
Creates a separate Fiber with a different IRuntime.
Parameters:
| Name | Type |
|---|---|
runtime | IRuntime |
Returns: QIO<Fiber<A1, E1>, never, R1>
map
▸ map<A2>(ab: (a: A1) => A2): QIO<A2, E1, R1>
Defined in packages/core/lib/main/QIO.ts:589
Applies transformation on the success value of the c.
Type parameters:
| Name |
|---|
A2 |
Parameters:
| Name | Type |
|---|---|
ab | (a: A1) => A2 |
Returns: QIO<A2, E1, R1>
par
▸ par<A2, E2, R2>(that: QIO<A2, E2, R2>): QIO<[A1, A2], E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:595
Runs the current IO with the provided IO in parallel.
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
Returns: QIO<[A1, A2], E1 | E2, R1 & R2>
provide
▸ provide(r1: R1): QIO<A1, E1>
Defined in packages/core/lib/main/QIO.ts:603
Provides the current instance of c the required env.
Parameters:
| Name | Type |
|---|---|
r1 | R1 |
Returns: QIO<A1, E1>
provideM
▸ provideM<E2, R2>(io: QIO<R1, E2, R2>): QIO<A1, E1 | E2, R2>
Defined in packages/core/lib/main/QIO.ts:609
Provides the current instance of c the required env that is accessed effect-fully.
Type parameters:
| Name |
|---|
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
io | QIO<R1, E2, R2> |
Returns: QIO<A1, E1 | E2, R2>
provideSome
▸ provideSome<R0>(fn: (R2: R0) => R1): QIO<A1, E1, R0>
Defined in packages/core/lib/main/QIO.ts:615
Provide only some of the environment
Type parameters:
| Name |
|---|
R0 |
Parameters:
| Name | Type |
|---|---|
fn | (R2: R0) => R1 |
Returns: QIO<A1, E1, R0>
provideSomeM
▸ provideSomeM<E2, R0>(qio: QIO<R1, E2, R0>): QIO<A1, E1 | E2, R0>
Defined in packages/core/lib/main/QIO.ts:621
Provide only some of the environment using an effect
Type parameters:
| Name |
|---|
E2 |
R0 |
Parameters:
| Name | Type |
|---|---|
qio | QIO<R1, E2, R0> |
Returns: QIO<A1, E1 | E2, R0>
race
▸ race<A2, E2, R2>(that: QIO<A2, E2, R2>): QIO<A1 | A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:627
Runs two IOs in parallel in returns the result of the first one.
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
Returns: QIO<A1 | A2, E1 | E2, R1 & R2>
raceWith
▸ raceWith<A2, E2, R2, A3, E3, A4, E4>(that: QIO<A2, E2, R2>, cb1: (exit: Exit<A1, E1>, fiber: Fiber<A2, E2>) => QIO<A3, E3>, cb2: (exit: Exit<A2, E2>, fiber: Fiber<A1, E1>) => QIO<A4, E4>): QIO<A3 | A4, E3 | E4, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:640
Executes two c instances in parallel and resolves with the one that finishes first and cancels the other.
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
A3 |
E3 |
A4 |
E4 |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
cb1 | (exit: Exit<A1, E1>, fiber: Fiber<A2, E2>) => QIO<A3, E3> |
cb2 | (exit: Exit<A2, E2>, fiber: Fiber<A1, E1>) => QIO<A4, E4> |
Returns: QIO<A3 | A4, E3 | E4, R1 & R2>
rejectWith
▸ rejectWith<E2>(error: E2): QIO<A1, E1 | E2, R1>
Defined in packages/core/lib/main/QIO.ts:669
Forcefully fails the current program with the provided error.
Type parameters:
| Name |
|---|
E2 |
Parameters:
| Name | Type |
|---|---|
error | E2 |
Returns: QIO<A1, E1 | E2, R1>
tap
▸ tap(fn: (A: A1) => void): QIO<A1, E1, R1>
Defined in packages/core/lib/main/QIO.ts:678
Helper on top of QIO.tapM Calls the provided effectfull function with the success value of this IO and ignores it's result and continues.
Parameters:
| Name | Type |
|---|---|
fn | (A: A1) => void |
Returns: QIO<A1, E1, R1>
tapM
▸ tapM<E2, R2>(io: (A1: A1) => QIO<unknown, E2, R2>): QIO<A1, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:685
Used to perform side-effects but ignore their values
Type parameters:
| Name |
|---|
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
io | (A1: A1) => QIO<unknown, E2, R2> |
Returns: QIO<A1, E1 | E2, R1 & R2>
zip
▸ zip<A2, E2, R2>(that: QIO<A2, E2, R2>): QIO<[A1, A2], E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:694
Combine the result of two cs sequentially and return a Tuple
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
Returns: QIO<[A1, A2], E1 | E2, R1 & R2>
zipWith
▸ zipWith<A2, E2, R2, C>(that: QIO<A2, E2, R2>, c: (a1: A1, a2: A2) => C): QIO<C, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:702
Combines the result of two cs and uses a combine function to combine their result
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
C |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
c | (a1: A1, a2: A2) => C |
Returns: QIO<C, E1 | E2, R1 & R2>
zipWithM
▸ zipWithM<A2, E2, R2, A3, E3, R3>(that: QIO<A2, E2, R2>, c: (a1: A1, a2: A2) => QIO<A3, E3, R3>): QIO<A3, E1 | E2 | E3, R1 & R2 & R3>
Defined in packages/core/lib/main/QIO.ts:711
Combines the result of two cs and uses a combine function that returns a c
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
A3 |
E3 |
R3 |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
c | (a1: A1, a2: A2) => QIO<A3, E3, R3> |
Returns: QIO<A3, E1 | E2 | E3, R1 & R2 & R3>
zipWithPar
▸ zipWithPar<A2, E2, R2, C>(that: QIO<A2, E2, R2>, c: (e1: A1, e2: A2) => C): QIO<C, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:720
Combine two c instances in parallel and use the combine function to combine the result.
Type parameters:
| Name |
|---|
A2 |
E2 |
R2 |
C |
Parameters:
| Name | Type |
|---|---|
that | QIO<A2, E2, R2> |
c | (e1: A1, e2: A2) => C |
Returns: QIO<C, E1 | E2, R1 & R2>
access
▸ Staticaccess<R, A>(cb: (R: R) => A): QIO<A, never, R>
Defined in packages/core/lib/main/QIO.ts:31
Creates a new c instance with the provided environment
Type parameters:
| Name |
|---|
R |
A |
Parameters:
| Name | Type |
|---|---|
cb | (R: R) => A |
Returns: QIO<A, never, R>
accessA
▸ StaticaccessA<A, E, R>(fn: (A: CB<A>, E: CB<E>, R: R) => void): QIO<A, E, R>
Defined in packages/core/lib/main/QIO.ts:38
Asynchronously access an env
Type parameters:
| Name |
|---|
A |
E |
R |
Parameters:
| Name | Type |
|---|---|
fn | (A: CB<A>, E: CB<E>, R: R) => void |
Returns: QIO<A, E, R>
accessM
▸ StaticaccessM<A1, E1, R1, R2>(cb: (R: R1) => QIO<A1, E1, R2>): QIO<A1, E1, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:48
Effectfully creates a new c instance with the provided environment
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
R2 |
Parameters:
| Name | Type |
|---|---|
cb | (R: R1) => QIO<A1, E1, R2> |
Returns: QIO<A1, E1, R1 & R2>
accessP
▸ StaticaccessP<A1, R1>(cb: (R: R1) => Promise<A1>): QIO<A1, Error, R1>
Defined in packages/core/lib/main/QIO.ts:56
Creates a new c instance with the provided environment by invoking a promise returning function.
Type parameters:
| Name |
|---|
A1 |
R1 |
Parameters:
| Name | Type |
|---|---|
cb | (R: R1) => Promise<A1> |
ap
▸ Staticap<A1, E1, R1, A2>(qio: QIO<(a: A1) => A2, E1, R1>, input: A1): QIO<A2, E1, R1>
Defined in packages/core/lib/main/QIO.ts:64
Converts a QIO of a function into a QIO of a value.
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
A2 |
Parameters:
| Name | Type |
|---|---|
qio | QIO<(a: A1) => A2, E1, R1> |
input | A1 |
Returns: QIO<A2, E1, R1>
call
▸ Staticcall<A1, E1, R1, T>(fn: (...t: T) => QIO<A1, E1, R1>, ...args: T): QIO<A1, E1, R1>
Defined in packages/core/lib/main/QIO.ts:74
Calls the provided Effect-full function with the provided arguments. Useful particularly when calling a recursive function with stack safety.
Type parameters:
| Name | Type |
|---|---|
A1 | - |
E1 | - |
R1 | - |
T | unknown[] |
Parameters:
| Name | Type |
|---|---|
fn | (...t: T) => QIO<A1, E1, R1> |
...args | T |
Returns: QIO<A1, E1, R1>
chain
▸ Staticchain<A1, E1, R1, A2, E2, R2>(fa: QIO<A1, E1, R1>, aFb: (a: A1) => QIO<A2, E2, R2>): QIO<A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:99
Serially executes one c after another.
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
fa | QIO<A1, E1, R1> |
aFb | (a: A1) => QIO<A2, E2, R2> |
Returns: QIO<A2, E1 | E2, R1 & R2>
encase
▸ Staticencase<A, E, T>(cb: (...t: T) => A): function
Defined in packages/core/lib/main/QIO.ts:112
Converts an effect-full function into a function that returns an QIO
Type parameters:
| Name | Type | Default |
|---|---|---|
A | - | never |
E | - | never |
T | unknown[] | unknown[] |
Parameters:
| Name | Type |
|---|---|
cb | (...t: T) => A |
Returns: function
encaseM
▸ StaticencaseM<A, E, R, T>(cb: (...t: T) => QIO<A, E, R>): function
Defined in packages/core/lib/main/QIO.ts:121
Converts an effect-full function return a QIO into a function that returns an QIO
Type parameters:
| Name | Type | Default |
|---|---|---|
A | - | never |
E | - | never |
R | - | unknown |
T | unknown[] | unknown[] |
Parameters:
| Name | Type |
|---|---|
cb | (...t: T) => QIO<A, E, R> |
Returns: function
encaseP
▸ StaticencaseP<A, T>(cb: (...t: T) => Promise<A>): function
Defined in packages/core/lib/main/QIO.ts:132
Converts a function returning a Promise to a function that returns an QIO
Type parameters:
| Name | Type |
|---|---|
A | - |
T | unknown[] |
Parameters:
| Name | Type |
|---|---|
cb | (...t: T) => Promise<A> |
Returns: function
env
▸ Staticenv<R1>(): QIO<R1, never, R1>
Defined in packages/core/lib/main/QIO.ts:150
Creates a QIO that needs an environment and when resolved outputs the same environment
Type parameters:
| Name | Default |
|---|---|
R1 | never |
Returns: QIO<R1, never, R1>
flatten
▸ Staticflatten<A1, E1, R1, A2, E2, R2>(qio: QIO<QIO<A2, E2, R2>, E1, R1>): QIO<A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:156
Unwraps a c
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
qio | QIO<QIO<A2, E2, R2>, E1, R1> |
Returns: QIO<A2, E1 | E2, R1 & R2>
fork
▸ Staticfork<A1, E1>(io: QIO<A1, E1>, runtime: IRuntime): QIO<Fiber<A1, E1>>
Defined in packages/core/lib/main/QIO.ts:164
Creates a new Fiber to run the given QIO.
Type parameters:
| Name |
|---|
A1 |
E1 |
Parameters:
| Name | Type |
|---|---|
io | QIO<A1, E1> |
runtime | IRuntime |
fromEither
▸ StaticfromEither<A, E>(exit: Either<E, A>): QIO<A, E>
Defined in packages/core/lib/main/QIO.ts:173
Creates an IO from Either
Type parameters:
| Name |
|---|
A |
E |
Parameters:
| Name | Type |
|---|---|
exit | Either<E, A> |
Returns: QIO<A, E>
fromExit
▸ StaticfromExit<A, E>(exit: Exit<A, E>): QIO<A, E>
Defined in packages/core/lib/main/QIO.ts:180
Creates an IO from Exit
Type parameters:
| Name |
|---|
A |
E |
Parameters:
| Name | Type |
|---|---|
exit | Exit<A, E> |
Returns: QIO<A, E>
if
▸ Staticif<A1, E1, R1, A2, E2, R2>(cond: boolean, left: QIO<A1, E1, R1>, right: QIO<A2, E2, R2>): QIO<A1 | A2, E1 | E2, R1 & R2>
Defined in packages/core/lib/main/QIO.ts:187
Alternative to ternary operator in typescript that forcefully narrows down the envs
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
A2 |
E2 |
R2 |
Parameters:
| Name | Type |
|---|---|
cond | boolean |
left | QIO<A1, E1, R1> |
right | QIO<A2, E2, R2> |
Returns: QIO<A1 | A2, E1 | E2, R1 & R2>
if0
▸ Staticif0<T>(...args: T): function
Defined in packages/core/lib/main/QIO.ts:197
A different flavour of qio.if]] that takes in functions instead of c instances.
Type parameters:
| Name | Type |
|---|---|
T | unknown[] |
Parameters:
| Name | Type |
|---|---|
...args | T |
Returns: function
interruptible
▸ Staticinterruptible<A1, E1>(cb: (res: CB<A1>, rej: CB<E1>) => ICancellable): QIO<A1, E1>
Defined in packages/core/lib/main/QIO.ts:213
NOTE: The default type for value 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.
Type parameters:
| Name | Default |
|---|---|
A1 | never |
E1 | never |
Parameters:
| Name | Type |
|---|---|
cb | (res: CB<A1>, rej: CB<E1>) => ICancellable |
Returns: QIO<A1, E1>
lazy
▸ Staticlazy<T, A1, E1, R1>(fn: (...T: T) => QIO<A1, E1, R1>): function
Defined in packages/core/lib/main/QIO.ts:223
Converts a normal function to a lazy function. A lazy function automatically becomes stack safe.
Type parameters:
| Name | Type |
|---|---|
T | unknown[] |
A1 | - |
E1 | - |
R1 | - |
Parameters:
| Name | Type |
|---|---|
fn | (...T: T) => QIO<A1, E1, R1> |
Returns: function
lift
▸ Staticlift<A1, E1>(cb: () => A1): QIO<A1, E1>
Defined in packages/core/lib/main/QIO.ts:232
Lifts an effectful hunk of code into a QIO.
Type parameters:
| Name | Default |
|---|---|
A1 | unknown |
E1 | never |
Parameters:
| Name | Type |
|---|---|
cb | () => A1 |
Returns: QIO<A1, E1>
map
▸ Staticmap<A1, E1, R1, A2>(fa: QIO<A1, E1, R1>, ab: (a: A1) => A2): QIO<A2, E1, R1>
Defined in packages/core/lib/main/QIO.ts:238
Transforms the success value using the specified function
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
A2 |
Parameters:
| Name | Type |
|---|---|
fa | QIO<A1, E1, R1> |
ab | (a: A1) => A2 |
Returns: QIO<A2, E1, R1>
never
▸ Staticnever(): QIO<never>
Defined in packages/core/lib/main/QIO.ts:251
Returns a QIO that never resolves.
Returns: QIO<never>
par
▸ Staticpar<A1, E1, R1>(ios: Array<QIO<A1, E1, R1>>): QIO<A1[], E1, R1>
Defined in packages/core/lib/main/QIO.ts:258
Runs multiple IOs in parallel. Checkout QIO.seq to run IOs in sequence.
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
Parameters:
| Name | Type |
|---|---|
ios | Array<QIO<A1, E1, R1>> |
Returns: QIO<A1[], E1, R1>
parN
▸ StaticparN<A1, E1, R1>(N: number, ios: Array<QIO<A1, E1, R1>>): QIO<A1[], E1, R1>
Defined in packages/core/lib/main/QIO.ts:280
Runs at max N IOs in parallel. Checkout QIO.par to run any number of QIOs in parallel
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
Parameters:
| Name | Type |
|---|---|
N | number |
ios | Array<QIO<A1, E1, R1>> |
Returns: QIO<A1[], E1, R1>
pipeEnv
▸ StaticpipeEnv<T, A1, E1, R1>(fn: (..._: T) => QIO<A1, E1, R1>, R: R1): function
Defined in packages/core/lib/main/QIO.ts:301
Takes in a function that returns a c and converts it to a function that returns an IO by providing it the given env.
Type parameters:
| Name | Type |
|---|---|
T | unknown[] |
A1 | - |
E1 | - |
R1 | - |
Parameters:
| Name | Type |
|---|---|
fn | (..._: T) => QIO<A1, E1, R1> |
R | R1 |
Returns: function
reject
▸ Staticreject<E1>(error: E1): QIO<never, E1>
Defined in packages/core/lib/main/QIO.ts:310
Creates a c that rejects with the provided error
Type parameters:
| Name |
|---|
E1 |
Parameters:
| Name | Type |
|---|---|
error | E1 |
Returns: QIO<never, E1>
resolve
▸ Staticresolve<A1>(value: A1): QIO<A1>
Defined in packages/core/lib/main/QIO.ts:317
Represents a constant value
Type parameters:
| Name |
|---|
A1 |
Parameters:
| Name | Type |
|---|---|
value | A1 |
Returns: QIO<A1>
runtime
▸ Staticruntime(): QIO<IRuntime>
Defined in packages/core/lib/main/QIO.ts:335
Returns the current runtime in a pure way.
seq
▸ Staticseq<A1, E1, R1>(ios: Array<QIO<A1, E1, R1>>): QIO<A1[], E1, R1>
Defined in packages/core/lib/main/QIO.ts:342
Executes the provided IOs in sequences and returns their intermediatory results as an Array. Checkout QIO.par to run multiple IOs in parallel.
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
Parameters:
| Name | Type |
|---|---|
ios | Array<QIO<A1, E1, R1>> |
Returns: QIO<A1[], E1, R1>
timeout
▸ Statictimeout<A>(value: A, duration: number): QIO<A>
Defined in packages/core/lib/main/QIO.ts:357
Resolves with the provided value after the given time
Type parameters:
| Name |
|---|
A |
Parameters:
| Name | Type |
|---|---|
value | A |
duration | number |
Returns: QIO<A>
try
▸ Statictry<A>(cb: () => A): QIO<A, Error>
Defined in packages/core/lib/main/QIO.ts:367
Tries to run an effect-full synchronous function and returns a QIO that resolves with the return value of that function and fails with an Error.
Type parameters:
| Name |
|---|
A |
Parameters:
| Name | Type |
|---|---|
cb | () => A |
tryM
▸ StatictryM<A1, E1, R1>(qio: () => QIO<A1, E1, R1>): QIO<A1, E1, R1>
Defined in packages/core/lib/main/QIO.ts:388
Takes in a effect-ful function that return a c and unwraps it.
This is an alias to c.flatten(QIO.lift(fn))
// An impure function that creates mutable state but also returns a c.
const FN = () => {
let count = 0
return c.try(() => count++)
}
// Using flatten
c.flatten(QIO.lift(FN))
// Using flattenM
c.tryM(FN)
Type parameters:
| Name |
|---|
A1 |
E1 |
R1 |
Parameters:
| Name | Type |
|---|---|
qio | () => QIO<A1, E1, R1> |
Returns: QIO<A1, E1, R1>
tryP
▸ StatictryP<A>(cb: () => Promise<A>): QIO<A, Error>
Defined in packages/core/lib/main/QIO.ts:394
Tries to run an function that returns a promise.
Type parameters:
| Name |
|---|
A |
Parameters:
| Name | Type |
|---|---|
cb | () => Promise<A> |
uninterruptible
▸ Staticuninterruptible<A1, E1>(fn: (res: CB<A1>, rej: CB<E1>) => unknown): QIO<A1, E1>
Defined in packages/core/lib/main/QIO.ts:401
Creates an IO from an async/callback based function ie. non cancellable. It tries to make it cancellable by delaying the function call.
Type parameters:
| Name | Default |
|---|---|
A1 | never |
E1 | never |
Parameters:
| Name | Type |
|---|---|
fn | (res: CB<A1>, rej: CB<E1>) => unknown |
Returns: QIO<A1, E1>
void
▸ Staticvoid(): QIO<void>
Defined in packages/core/lib/main/QIO.ts:420
Returns a QIO of void.
Returns: QIO<void>