RE: polymorphic type in state of state monad
| | type State = Term a = [a] | | data M a = M (State - IO(State,a)) | | | | GHC yields a error message Illegal polymorphic type. | | How to resolve this? I can tell you what it happening. If you have -fglasgow-exts on, the type for State is short for type State = forall a. Term a = [a] And then you can't use that polymorphic type in the argument of a tuple, as you are doing in the next line. Without -fglasgow-exts (i.e. in Haskell 98) the first line is plain illegal: 'a' is not in scope. But GHC may not produce as perspicuous a message as it should for that. Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: polymorphic type in state of state monad
G'day all. On Tue, Mar 11, 2003 at 08:34:06AM +1300, Tom Pledger wrote: If, on the other hand, you want to vary the state type *during* a single monadic computation, it gets messy. You could try one of the following. Very often, you just want to vary the state type for some portion of the computation then go back to the original. In that case, a simpler solution is to stack a new state monad transformer (such as Control.Monad.State.StateT) on top of your existing state monad for the part where you need it. Cheers, Andrew Bromage ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell