Difference between revisions of "PFP Laboratory 8"

From Marek Běhálek Wiki
Jump to navigation Jump to search
(Created page with "== Monads == * Consider you have a type: <syntaxhighlight lang="Haskell"> newtype State s a = State { runState :: s -> (s, a) } </syntaxhighlight> Make this type the instance...")
 
Line 6: Line 6:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Make this type the instance of <code>Monad</code>
 
Make this type the instance of <code>Monad</code>
 +
 +
<div class="mw-collapsible mw-collapsed" data-collapsetext="Hide solution" data-expandtext="Show solution">
 +
<syntaxhighlight lang="Haskell">
 +
...
 +
</syntaxhighlight>
 +
</div>
 +
<div style="clear:both"></div>

Revision as of 08:12, 24 October 2022

Monads

  • Consider you have a type:
newtype State s a = State { runState :: s -> (s, a) }

Make this type the instance of Monad

...