init::io

init/src/io.mo

typeRawIO#
pub type RawIO A {
    io A
}
defRawIO.pure#
pub def RawIO.pure (a : A) : RawIO A

Construct a RawIO value wrapping a pure value.

defRawIO.bind#
pub def RawIO.bind (a : RawIO A) (f : A -> RawIO B) : RawIO B

Unwrap a RawIO value and apply a continuation.

instance_#
pub instance Monad RawIO {
    def pure (a : A) : RawIO A :=
        RawIO.pure a
    def bind (a : RawIO A) (f : A -> RawIO B) : RawIO B :=
        RawIO.bind a f
}
typeIO#
pub type IO A {
    mk (raw : RawIO A)
}

IO is the user-facing IO type. It wraps RawIO and can be extended with state, exceptions, and other capabilities. Today it is a thin wrapper that delegates to RawIO.

defIO.pure#
pub def IO.pure (a : A) : IO A

Construct an IO value from a pure value.

instance_#
pub instance Monad IO {
    def pure (a : A) : IO A :=
        IO.pure a
    def bind (a : IO A) (f : A -> IO B) : IO B :=
        IO.bind a f
}