Ralf Hinze answers my question:
|> Can anyone provide a definition of `thread' equivalent to this:
|>
|> > thread :: Monad m => [a -> m a] -> a -> m a
|> > thread [] a = return a
|> > thread (k:ks) a = k a >>= thread ks
|>
|> not using pattern matching (eg. using map or fold) that does not have
|> a space leak?
very simply with:
|> thread = foldr (\k sol a -> k a >>= sol) return
even via standard steps, making my question look even more like a
homework assignment. :-)
Valery Trifonov has also given this result, and provided an amusing
alternative:
> thread = foldr (flip (.) (flip (>>=)) . flip (.)) return
:-)
Perhaps I should go back to school... :-)
Graeme.