Ejemplo n.º 1
0
            /**
             * 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();
            }
Ejemplo n.º 2
0
 public C(StateMonad m)
 {
     this.m = m;
 }