nim_iterator_stream_experiment/monad/io

    Dark Mode
Search:
Group by:

The IO monad from Haskell.

It lets one build a computation that has no parameters. It can also be used as a wrapper for computations that interact with external resources such as memory management, FFI, I/O, etc. .

Examples can be found here.

Types

IO[T] = () -> T
  Source Edit

Procs

proc run[T](self: IO[T]): T
  Source Edit

Funcs

func toIO[T](value: T): IO[T]
  Source Edit
func map[A; B](self: IO[A]; f: A -> B): IO[B]
  Source Edit
func flatMap[A; B](self: IO[A]; f: A -> IO[B]): IO[B]
  Source Edit
func bracket[A; B](before: IO[A]; between: A -> B; after: A -> Unit): IO[B]
If an exception is raised anywhere in before or between, after will not be executed.   Source Edit
func tryBracket[A; B](before: IO[A]; `try`: A -> B; `finally`: A -> Unit): IO[B]
Any exception raised in try will be reraised in the returned IO. Whether an exception was raised, finally will be executed once.   Source Edit