PFP Laboratory 11

From Marek Běhálek Wiki
Revision as of 08:30, 22 November 2022 by Beh01 (talk | contribs) (Created page with "== State monad== * In your prefered programming language, define a function representing a state: <code>State s a :: s -> (s,a)</code>. For example in C#, it will be someth...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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#).