Idris2Doc : Data.Linear.Token

Data.Linear.Token

(source)

Reexports

importpublic Data.Linear

Definitions

dataWorld : Type
  An empty type for tagging linear computations that can be wrapped in `IO`

Totality: total
Visibility: public export
Hints:
HasIO (PureWorld)
HasIO (PureWorld)
Lift1WorldIO
0T1 : Type->Type
  A linear token used in computations with mutable linear state.

The idea is that mutable state (mutable references, arrays, pointers,
and so on) can only be accessed in the presence of the linear token
that was used to create the mutable resource.

The advantage of using linear types over the `ST` monad: They come
without the (significant) performance overhead of monadic code in
Idris. Like the `ST` monad, this provides safe resource handling, because
the function for running linear computations over a `T1` (function
`run1`) must work with function argument `f` of type
`forall s . (1 t : T1 s) -> R1 s a`, that is, mutable references cannot
leak out of the linear computation and remain usable.

Totality: total
Visibility: export
dataR1 : Type->Type->Type
  The result of a stateful linear computation.

It pairs the result value with a new linear token.

Totality: total
Visibility: public export
Constructor: 
(#) : a-> (1_ : T1s) ->R1sa
mapR1 : (a->b) -> (1_ : R1sa) ->R1sb
  `R1` is a functor, but since `map` does not have the correct
quantities, this is what we use instead.

Totality: total
Visibility: export
0F1 : Type->Type->Type
  A linear computation operating on resources `rs` that produces a
result of type `a` with a new token operating on resources `ss`.

Totality: total
Visibility: public export
0F1' : Type->Type
  Convenience alias for `F1 s ()`.

Totality: total
Visibility: public export
unit1 : F1's
  The dummy action that performs no effect at all.

Totality: total
Visibility: export
mapF1 : (a->b) ->F1sa->F1sb
  `F1` is a functor, but since it is a function type, we cannot
implement an interface for it (but see `Control.Monad.Pure`).

Totality: total
Visibility: export
run1 : F1sa->a
  Runs a linear computation by providing it with its own linear token.

Since this is universally quantified over `s`, it is impossible that
callers can freely choose the tag for the state thread and thus reuse
their mutable references.

It is also not possible that the linear token paired with the
corresponding mutable state leaks into the outer world, because
the result value must have quantity omega (see the definition of `R1`).

Totality: total
Visibility: export
primRun : F1Worlda->PrimIOa
  Runs a linear computation tagged with `[World]` as a primitive
`IO` action.

Totality: total
Visibility: export
runIO : HasIOio=>F1Worlda->ioa
  Convenience wrapper around `primRun`.

Totality: total
Visibility: export
toF1 : PrimIOa->F1Worlda
  Safely uses a primitive `IO` action in `F1 [World]`.

Totality: total
Visibility: export
ioToF1 : IOa->F1Worlda
  Safely uses an `IO` action in `F1 [World]`.

Totality: total
Visibility: export
when1 : Bool-> Lazy (F1's) ->F1's
  Run the given stateful computation if the boolean value is `True`.

Totality: total
Visibility: export
forN : Nat->F1's->F1's
  Run a stateful computation `n` times

Totality: total
Visibility: export
ffi : PrimIOa->F1sa
  Use this to convert a primitive FFI call to a linear function
of type `F1 rs a`.

This is typically used for running effectful computations that
do not produce an interesting result.
See `Data.Linear.Ref1.prim__writeRef` and
the corresponding `Data.Linear.Ref1.write1` for a usage example.

Totality: total
Visibility: export
interfaceLift1 : Type-> (Type->Type) ->Type
  An interface for wrapping linear computations in a monadic context.

This allows us to deal with pure as well as effectful computations.
Effectful computations should use `World` as the tag for `s`, while
pure computations should use universal quantification.

Parameters: s, f
Constraints: Monad f
Methods:
lift1 : F1sa->fa

Implementations:
Lift1s (Pures)
Lift1s (Pures)
Lift1WorldIO
lift1 : Lift1sf=>F1sa->fa
Totality: total
Visibility: public export
0IO1 : Type->Type
Totality: total
Visibility: public export
0LIO : (Type->Type) ->Type
  Convenience alias for `Lift1 World`

Totality: total
Visibility: public export
dataDebugFlag : Type
Totality: total
Visibility: public export
Constructors:
NoDebugging : DebugFlag
Debugging : DebugFlag
debug1 : String->F1's
  This is a utility for debugging complex linear algorithms
similar to but more convenient than the one find in module
`Debug.Trace`.

Strictly speaking, using this breaks referential transparency.

Totality: total
Visibility: export
debugIf1 : DebugFlag=>String->F1's
  Like `debug1` but can be conveniently turned on and off via an
auto-implicit flag.

Totality: total
Visibility: export