oops, I take that back. It only appears to work if you are sloppy: x :: (Monad m) => m a x = undefined
y :: (Monad m) => m b y = undefined g :: (Monad m) => a -> b -> m c g = undefined ex1 :: (Monad m) :: m c ex1 = (g =<< x) =<< y But, if you try to pin down the types you find it only works because they are not all the same Monad m. a :: (Int -> Int) a = return 1 b :: Maybe Int b = Just 2 h :: Int -> Int -> Maybe Int h a b = return (a + b) ex5 :: Maybe Int ex5 = (h =<< a) =<< b :) j. At Thu, 12 Feb 2009 18:04:45 -0600, Jeremy Shaw wrote: > > Hello, > > You could do: > > (f =<< x) =<< y > > ? > > - jeremy > > > > At Thu, 12 Feb 2009 23:36:19 +0000, > Edsko de Vries wrote: > > > > Hi, > > > > I can desugar > > > > do x' <- x > > f x' > > > > as > > > > x >>= \x -> f x' > > > > which is clearly the same as > > > > x >>= f > > > > However, now consider > > > > do x' <- x > > y' <- y > > f x' y' > > > > desugared, this is > > > > x >>= \x -> y >>= \y' -> f x' y' > > > > I can simplify the second half to > > > > x >>= \x -> y >>= f x' > > > > but now we are stuck. I feel it should be possible to write something like > > > > x ... y ... f > > > > or perhaps > > > > f ... x ... y > > > > the best I could come up with was > > > > join $ return f `ap` x `ap` y > > > > which is not terrible but quite as easy as I feel this should be. Any hints? > > > > Edsko > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe