std.writer

Modules

Implementation of the Writer type

Types

type Writer w a = { value : a, writer : w }

The writer Monad

Values

let functor : forall w . [std.monoid.Monoid w] -> std.functor.Functor (std.writer.Writer w)

A Functor represents an action on a parameterized type which does not change the structure with the mapped type.

The following laws should hold:

  • map id == id
  • map (f << g) == map f << map g

let applicative : forall w .
    [std.monoid.Monoid w] -> std.applicative.Applicative (std.writer.Writer w)

A Functor with application.

The following laws should hold:

  • wrap id <*> v = v
  • wrap (<<) <> u <> v <> w = u <> (v <*> w)
  • wrap f <*> wrap x = wrap (f x)
  • u <> wrap y = wrap (\g -> g x) <> u

let monad : forall w . [std.monoid.Monoid w] -> std.monad.Monad (std.writer.Writer w)

A generalised interface for imperatively sequencing actions

let tell w : forall w . w -> std.writer.Writer w ()