[Haskell-cafe] Monad transformers [Stacking monads]
andrewcoppin at btinternet.com
Tue Oct 7 14:27:57 EDT 2008
The good news: I managed to turn ResultSet into a monad transformer.
The bad news: It generates the entire result set before returning
anything to the caller.
In other words, it works perfectly for finite result sets, and locks up
forever on infinite result sets. Since the entire *point* of the monad
is to handle infinite result sets correctly, that's kind-of a problem.
And one that I see absolutely no way of fixing. :-(
Basically, the core code is something like
raw_bind :: (Monad m) => [[x]] -> (x -> m (ResultSet y)) -> m
raw_bind  f = return empty
raw_bind (xs:xss) f = do
rsYs <- mapM f xs
rsZ <- raw_bind xss f
return (foldr union (cost rsZ) rsYs)
As you can see, this generates all of rsZ before attempting to return
anything to the caller. And I'm really struggling to see any way to
More information about the Haskell-Cafe