コード例 #1
0
ファイル: StateMonadTest.cs プロジェクト: BoykoDmitry/csharp
            /**
             * 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();
            }
コード例 #2
0
ファイル: StateMonadTest.cs プロジェクト: BoykoDmitry/csharp
 public C(StateMonad m)
 {
     this.m = m;
 }