Esempio n. 1
0
 public override Func <CacheEntry <K, V>, Monad <C> > Kleisli <B, C>(Func <CacheEntry <K, V>, Monad <B> > fAtB, Func <B, Monad <C> > fBtC)
 {
     return((a) =>
     {
         Monad <B> result = null;
         Lock.EnterWriteLock();
         try
         {
             foreach (var element in cacheDict.Values)
             {
                 if (result == null)
                 {
                     result = fAtB(element);
                 }
                 else
                 {
                     result.Concatenate(fAtB(element));
                 }
             }
         }
         finally
         {
             Lock.ExitWriteLock();
         }
         return result.Bind(fBtC);
     });
 }
Esempio n. 2
0
        public override Func <A, Monad <C> > Kleisli <B, C>(Func <A, Monad <B> > fAtB, Func <B, Monad <C> > fBtC)
        {
            return((a) =>
            {
                Monad <B> result = null;
                foreach (A element in list)
                {
                    if (result == null)
                    {
                        result = fAtB(element);
                    }
                    else
                    {
                        result.Concatenate(fAtB(element));
                    }
                }

                return result.Bind(fBtC);
            });
        }