[Haskell] Mixing monadic and non-monadic functions

Sean E. Russell haskell at ser.fdns.net
Tue Mar 23 10:29:26 EST 2004


Hello,

I posted this question to comp.lang.functional, and someone suggested that I 
try this group instead.

I'm struggling with monads.  Well, not monads themselves, but mixing them with 
non-monadic functions.

Here's my base case:

	someFunc :: String -> IO [a]
	...
		ax <- someFunc a
		bx <- someFunc b
		assertBool "fail" $ length ax == length bx

I don't like the assignments; the typing is redundant, if I have a lot of 
asserts like this, and the "variables" are temporary.  What I'd much rather 
have is:

	...
		assertBool "fail" $ (length $ someFunc a) == (length $ someFunc b)

which is more readable, to my eye.

The only solution which has been suggested that may work is liberal use of the 
liftM variants, but this gets *really* tedious and obtuse.

Is there an elegant way to do what I want to do, or am I stuck with 
procedural-style assignments and bunches of temp vars?

Thanks!

-- 
### SER   
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido
### http://www.germane-software.com/~ser  jabber.com:ser  ICQ:83578737 
### GPG: http://www.germane-software.com/~ser/Security/ser_public.gpg


More information about the Haskell mailing list