PFP Laboratory 11

From Marek Běhálek Wiki
Jump to navigation Jump to search

State monad

  • In your prefered programming language, define a function representing a state: State s a :: s -> (s,a). For example in C#, it will be something like this:
delegate (TState State, T Value) State<TState, T>(TState state)
  • Implement functions bind and return as it is defined for monads (or SelectMany, if you are using C#).