/** * Simple example of running a string through a calculation involving * destructive update modelled by a state monad. * * @param initial the starting string. * @return the result of running the string through the computation. */ public static String ToUpperCase(String initial) { var m = new StateMonad(); // do a <- lookup // mutate(a.toUpperCase) // lookup Computation c = m.Bind(m.Lookup(), new C(m)); return((String)m.Run(c, initial).Value()); }
private Computation Make(string a) { return(m.Sequence(m.Mutate(a.ToUpper()), m.Lookup())); }