Combining monads
Mark T.B. Carroll
Mark.Carroll@Aetion.com
Sat, 12 Apr 2003 09:52:58 -0400 (EDT)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
--481034957-302199926-1050155578=:555
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hello! I am trying and failing to use one monad in another. A tiny example
is enclosed, where I try to use IO to help along a State-ful computation.
Is the real mistake in do_next? Is there a minimal rewrite that will get
this working that I can use as a template for other things? Or, is there a
good tutorial somewhere on this type of thing? Any pointers are much
appreciated!
-- Mark
--481034957-302199926-1050155578=:555
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="Test.hs"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.44.0304120952580.555@cicero.aetion.internal>
Content-Description: Example of incompetence
Content-Disposition: attachment; filename="Test.hs"
aW1wb3J0IENvbnRyb2wuTW9uYWQuU3RhdGUNCmltcG9ydCBEYXRhLkxpc3QN
Cg0KZ2V0X2xlbmd0aCA6OiBTdHJpbmcgLT4gSU8gSW50DQoNCmdldF9sZW5n
dGggbmFtZSA9IA0KICAgIGRvIGNvbnRlbnRzIDwtIHJlYWRGaWxlIG5hbWUN
CiAgICAgICByZXR1cm4gKGxlbmd0aCAobGluZXMgY29udGVudHMpKQ0KDQp1
cGRhdGVfYmVzdF93aXRoIDo6IChTdHJpbmcsIEludCkgLT4gU3RhdGVUIChT
dHJpbmcsIEludCkgSU8gKCkNCg0KdXBkYXRlX2Jlc3Rfd2l0aCAoY3VycmVu
dF9uYW1lLCBjdXJyZW50X2NvdW50KSA9DQogICAgZG8gKGJlc3RfbmFtZSwg
YmVzdF9jb3VudCkgPC0gZ2V0DQogICAgICAgaWYgY3VycmVudF9jb3VudCA+
IGJlc3RfY291bnQgDQoJICB0aGVuIHB1dCAoY3VycmVudF9uYW1lLCBjdXJy
ZW50X2NvdW50KQ0KCSAgZWxzZSByZXR1cm4gKCkNCg0KZG9fbmV4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