Idris2Doc : Control.Monad.MCancel

Control.Monad.MCancel

(source)

Reexports

importpublic Control.Monad.MErr

Definitions

dataOutcome : ListType->Type->Type
Totality: total
Visibility: public export
Constructors:
Succeeded : a->Outcomeesa
Error : HSumes->Outcomeesa
Canceled : Outcomeesa

Hints:
Applicative (Outcomees)
AllEqes=>Eqa=>Eq (Outcomeesa)
Foldable (Outcomees)
Functor (Outcomees)
Monad (Outcomees)
AllShowes=>Showa=>Show (Outcomeesa)
Traversable (Outcomees)
toOutcome : Resultesa->Outcomeesa
Totality: total
Visibility: export
fromOutcome : Outcomeesa->Resultes (Maybea)
Totality: total
Visibility: export
0Poll : (ListType->Type->Type) ->Type
Totality: total
Visibility: public export
interfaceMCancel : (ListType->Type->Type) ->Type
Parameters: f
Constraints: MErr f
Methods:
canceled : fes ()
  Requests self-cancelation of the current fiber (computational thread).
uncancelable : (Pollf->fesa) ->fesa
  Masks cancelation on the current fiber. The argument to `body` of type `Poll f` is a
natural transformation `f ~> f` that enables polling. Polling causes a fiber to unmask
within a masked region so that cancelation can be observed again.

In the following example, cancelation can be observed only within `fb` and nowhere else:

```
uncancelable $ \poll => fa >> poll(fb) >> fc
```

If a fiber is canceled while it is masked, the cancelation is suppressed for as long as the
fiber remains masked. Whenever the fiber is completely unmasked again, the cancelation will
be respected.

Masks can also be stacked or nested within each other. If multiple masks are active, all
masks must be undone so that cancelation can be observed. In order to completely unmask
within a multi-masked region the poll corresponding to each mask must be applied to the
effect, outermost-first.

```
uncancelable $ \p1 =>
uncancelable $ \p2 =>
fa >> p2(p1(fb)) >> fc
```

The following operations are no-ops:

1. Polling in the wrong order
2. Subsequent polls when applying the same poll more than once: `poll(poll(fa))` is
equivalent to `poll(fa)`
3. Applying a poll bound to one fiber within another fiber
onCancel : fesa->f [] () ->fesa
  Registers a finalizer that is invoked if cancelation is observed during the evaluation of
`fa`. If the evaluation of `fa` completes without encountering a cancelation, the finalizer
is unregistered before proceeding.

Note that if `fa` is uncancelable (e.g. created via `uncancelable`) then `fin` won't be
fired.

```
onCancel (uncancelable(_ => canceled)) fin <-> F.unit
```

During finalization, all actively registered finalizers are run exactly once. The order by
which finalizers are run is dictated by nesting: innermost finalizers are run before
outermost finalizers. For example, in the following program, the finalizer `f1` is run
before the finalizer `f2`:

```
onCancel (onCancel canceled f1) f2
```

In accordance with the type signatur, finalizers must not throw observable
errors
canceled : MCancelf=>fes ()
  Requests self-cancelation of the current fiber (computational thread).

Totality: total
Visibility: public export
uncancelable : MCancelf=> (Pollf->fesa) ->fesa
  Masks cancelation on the current fiber. The argument to `body` of type `Poll f` is a
natural transformation `f ~> f` that enables polling. Polling causes a fiber to unmask
within a masked region so that cancelation can be observed again.

In the following example, cancelation can be observed only within `fb` and nowhere else:

```
uncancelable $ \poll => fa >> poll(fb) >> fc
```

If a fiber is canceled while it is masked, the cancelation is suppressed for as long as the
fiber remains masked. Whenever the fiber is completely unmasked again, the cancelation will
be respected.

Masks can also be stacked or nested within each other. If multiple masks are active, all
masks must be undone so that cancelation can be observed. In order to completely unmask
within a multi-masked region the poll corresponding to each mask must be applied to the
effect, outermost-first.

```
uncancelable $ \p1 =>
uncancelable $ \p2 =>
fa >> p2(p1(fb)) >> fc
```

The following operations are no-ops:

1. Polling in the wrong order
2. Subsequent polls when applying the same poll more than once: `poll(poll(fa))` is
equivalent to `poll(fa)`
3. Applying a poll bound to one fiber within another fiber

Totality: total
Visibility: public export
onCancel : MCancelf=>fesa->f [] () ->fesa
  Registers a finalizer that is invoked if cancelation is observed during the evaluation of
`fa`. If the evaluation of `fa` completes without encountering a cancelation, the finalizer
is unregistered before proceeding.

Note that if `fa` is uncancelable (e.g. created via `uncancelable`) then `fin` won't be
fired.

```
onCancel (uncancelable(_ => canceled)) fin <-> F.unit
```

During finalization, all actively registered finalizers are run exactly once. The order by
which finalizers are run is dictated by nesting: innermost finalizers are run before
outermost finalizers. For example, in the following program, the finalizer `f1` is run
before the finalizer `f2`:

```
onCancel (onCancel canceled f1) f2
```

In accordance with the type signatur, finalizers must not throw observable
errors

Totality: total
Visibility: public export
guaranteeCase : MCancelf=>fesa-> (Outcomeesa->f [] ()) ->fesa
  Specifies an effect that is always invoked after evaluation of `fa` completes, but depends
on the outcome.

See also `bracketCase` for a more powerful variant

Totality: total
Visibility: export
guarantee : MCancelf=>fesa->f [] () ->fesa
  Specifies an effect that is always invoked after evaluation of `fa` completes, regardless
of the outcome.

See `guaranteeCase` for a more powerful variant

Totality: total
Visibility: export
onAbort : MCancelf=>fesa->f [] () ->fesa
  Guarantees to run the given cleanup hook in case a fiber
has been canceled or failed with an error.

See `guaranteeCase` for additional information.

Totality: total
Visibility: export
bracketFull : MCancelf=> (Pollf->fesa) -> (a->fesb) -> (a->Outcomeesb->f [] ()) ->fesb
  A pattern for safely interacting with effectful lifecycles.

If `acquire` completes successfully, `use` is called. If `use` succeeds, fails, or is
canceled, `release` is guaranteed to be called exactly once.

If `use` succeeds the returned value `B` is returned. If `use` returns an exception, the
exception is returned.

`acquire` is uncancelable by default, but can be unmasked. `release` is uncancelable. `use`
is cancelable by default, but can be masked.

Totality: total
Visibility: export
bracketCase : MCancelf=>fesa-> (a->fesb) -> (a->Outcomeesb->f [] ()) ->fesb
  A pattern for safely interacting with effectful lifecycles.

If `acquire` completes successfully, `use` is called. If `use` succeeds, fails, or is
canceled, `release` is guaranteed to be called exactly once.

`acquire` is uncancelable. `release` is uncancelable. `use` is cancelable by default, but
can be masked.

Totality: total
Visibility: export
bracket : MCancelf=>fesa-> (a->fesb) -> (a->f [] ()) ->fesb
  A pattern for safely interacting with effectful lifecycles.

If `acquire` completes successfully, `use` is called. If `use` succeeds, fails, or is
canceled, `release` is guaranteed to be called exactly once.

`acquire` is uncancelable. `release` is uncancelable. `use` is cancelable by default, but
can be masked.

Totality: total
Visibility: export