Brian Beckman: The Zen of Stateless State - The State Monad - Part 2
- Posted: Nov 20, 2008 at 1:38 PM
- 104,581 Views
- 4 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Exercise 2: go from labeling a tree to doing a constrained
container computation, as in WPF. Give everything a
bounding box, and size subtrees to fit inside their
Exercise 3: promote @return and @bind into an abstract
class "M" and make "SM" a subclass of that.
Exercise 4 (HARD): go from binary tree to n-ary tree.
Exercise 5: Abstract from n-ary tree to IEnumerable; do
everything in LINQ! (Hint: SelectMany).
Exercise 6: Go look up monadic parser combinators and
implement an elegant parser library on top of your new
state monad in LINQ.
Exercise 7: Verify the Monad laws, either abstractly
(pencil and paper), or mechnically, via a program, for the
Exercise 8: Design an interface for the operators @return
and @bind and rewrite the state monad so that it implements
this interface. See if you can enforce the monad laws
(associativity of @bind, left identity of @return, right
identity of @return) in the interface implementation.
Exercise 9: Look up the List Monad and implement it so that it implements the same interface.
Exercise 10: deconstruct this entire example by using
destructive updates (assignment) in a discipline way that
treats the entire CLR and heap memory as an "ambient
monad." Identify the @return and @bind operators in this
monad, implement them explicitly both as virtual methods
and as interface methods.