Threading monads

Mark T.B. Carroll Mark.Carroll@Aetion.com
Thu, 10 Apr 2003 12:18:32 -0400 (EDT)


Occasionally I have a non-monadic function (call it "x") that takes a
function (call it "y") as an argument and uses it for stuff.

Then, one day I inevitably want to pass it a y that needs to do something
monadically: e.g. when I wanted unfoldM instead of unfoldr. So, I have to
rewrite x accordingly.

If I want to write an x that is open to taking a monadic y but doesn't
require it to be monadic, should I maybe write it monadically and provide
a wrapper that puts non-monadic y's in the Identity monad? Might this
wrapping approach cause less efficient code than writing an alternative
non-monadic x for non-monadic y's?

Am I making any sense at all? (-:

-- Mark