Logo Orsak

Effect<'r, 'a, 'e> Type

Describes an effect that can either succeed with , or fail with . The effect is 'cold', and only starts when run with an .

Effects are usually written with the eff computation expression, and created from interfaces that describe side effects with Effect.Create. The environment is inferred from what the effect uses, and supplied when the effect is run.

Example

 let greet () = eff {
     let! name = Console.readLine ()
     do! Console.writeLine $"Hello {name}"
 }

 // at the composition root, with an environment providing the console effects:
 let! result = greet () |> Effect.run env
val greet: unit -> 'a
val result: obj

Union cases

Union case Description

Effect EffectDelegate<'r, 'a, 'e>

Full Usage: Effect EffectDelegate<'r, 'a, 'e>

Parameters:
Item : EffectDelegate<'r, 'a, 'e>

Instance members

Instance member Description

this.Run

Full Usage: this.Run

Parameters:
    r : 'r

Returns: AsyncResult<'a, 'e>
Modifiers: inline

Starts the effect. A that can be awaited to get the result of the effect

r : 'r
Returns: AsyncResult<'a, 'e>

this.RunOrFail

Full Usage: this.RunOrFail

Parameters:
    r : 'r

Returns: Task<'a>
Modifiers: inline

Starts the effect, and raises an exception in case of error. Prefer Run. A that can be awaited to get the result of the effect

r : 'r
Returns: Task<'a>

Static members

Static member Description

f <*> e

Full Usage: f <*> e

Parameters:
    f : Effect<'env, ('arg -> 'res), ^a>
    e : Effect<'env, 'arg, ^a>

Returns: Effect<'env, 'res, ^a>
Modifiers: inline
Type parameters: ^a (requires (static member op_Addition : ^a * ^a -> ^a))

Implements Apply on the effect, making it an applicative

f : Effect<'env, ('arg -> 'res), ^a>
e : Effect<'env, 'arg, ^a>
Returns: Effect<'env, 'res, ^a>

h >>= f

Full Usage: h >>= f

Parameters:
Returns: Effect<'r, 'b, 'e>
Modifiers: inline

Implements Bind on the effect, as an operator

h : Effect<'r, 'a, 'e>
f : 'a -> Effect<'r, 'b, 'e>
Returns: Effect<'r, 'b, 'e>

Effect.Bind(h, f)

Full Usage: Effect.Bind(h, f)

Parameters:
    h : Effect<'env, 'arg, 'err>
    f : 'arg -> Effect<'env, 'res, 'err>

Returns: Effect<'env, 'res, 'err>
Modifiers: inline
Type parameters: 'res

Implements Bind on the effect, which together with the functor Return makes it a Monad

h : Effect<'env, 'arg, 'err>
f : 'arg -> Effect<'env, 'res, 'err>
Returns: Effect<'env, 'res, 'err>

Effect.Map(h, f)

Full Usage: Effect.Map(h, f)

Parameters:
    h : Effect<'r, 'a, 'e>
    f : 'a -> 'b

Returns: Effect<'r, 'b, 'e>
Modifiers: inline

Implements Map on the effect, making it a Functor

h : Effect<'r, 'a, 'e>
f : 'a -> 'b
Returns: Effect<'r, 'b, 'e>

Effect.Return(arg1)

Full Usage: Effect.Return(arg1)

Parameters:
Returns: 'a -> Effect<'r, 'a, 'e>
Modifiers: inline

Implements Return on the effect, given an effect of the type to return, for the type alone

arg0 : Effect<'r, 'a, 'e>
Returns: 'a -> Effect<'r, 'a, 'e>

Effect.Return(a)

Full Usage: Effect.Return(a)

Parameters:
    a : 'a

Returns: Effect<'r, 'a, 'e>
Modifiers: inline

Implements Return on the effect

a : 'a
Returns: Effect<'r, 'a, 'e>

Type something to start searching.