Skip to content

Instantly share code, notes, and snippets.

@iskeld
iskeld / NaryTreeStateMonad
Created May 29, 2014 20:04
F# State Monad implementation for n-ary tree (based on "The Zen of Stateless State" video by Brian Beckman)
open System
type Tree<'a> =
| Leaf of 'a
| Branch of Tree<'a> list
type StateMonad<'state, 'content> = StateMonad of ('state -> ('state * 'content))
let testTree =
Branch [