[Haskell] Any way to change state type in a monad?

Ben.Yu at combined.com Ben.Yu at combined.com
Tue Jul 13 14:15:27 EDT 2004

Hi, I'm trying to implement some rule combinators.

I'm hoping my combinators can change the state type implicitly passed

Basically, a rule should be something like:

newtype Rule m u u' = ...

where it takes an input u and returns type u' as the result. m represents
an inner monad.

For the supported operations, I'd like to bind my rules with compatible
output and input types;
`mplus` rules  with same input and output types;
'try' a rule without changing state in m;
tell if a rule succeeded or failed and take action accordingly.

For the latter two, it has been pretty tricky to me. Looks like many monads
don't support such functionality.

It does not seem like possible to do this in a monad because Monad is for
type constructors with only one parameter while

Rule m u u' and Rule m u' u'' obviously cannot be in the same monad type.

So, is this design inherently flawed or there's just no such implementation



This message is intended only for the addressee and may contain information
that is confidential or privileged. Unauthorized use is strictly prohibited
and may be unlawful. If you are not the intended recipient, or the person
responsible for delivering to the intended recipient, you should not read,
copy, disclose or otherwise use this message, except for the purpose of
delivery to the addressee. If you have received this email in error, please
delete and advise us immediately.

More information about the Haskell mailing list