multiple methods pattern bug(?)

Simon Marlow simonmar at microsoft.com
Thu Apr 11 09:52:36 EDT 2002


> the following instance declaration doesn't work any
> more with ghc-5.02.3, it worked before.
> 
> > newtype ST state a = ST { unST :: state -> (a,state) }
> > 
> > instance Monad (ST c) where
> >  return x  = ST (\state -> (x,state))  
> > (m >>= f) = ST (\state -> let (x,state1) = unST m state
> >                               (y,state2) = unST (f x) state1
> >                           in (y,state2)) 
> 
> Error message:
>     Can't handle multiple methods defined by one pattern binding
> 	(m >>= f)
> 	    = ST (\ state
> 		      -> let
> 			   (y, state2) = ...
> 			   (x, state1) = ...
> 			 in (y, state2))
> 
> What can I do instead?

Remove the parentheses on the left hand side - that's not legal Haskell
98.  The error message is a bit cryptic though, the renamer should
really spot that it isn't a valid pattern binding first.

Cheers,
	Simon



More information about the Glasgow-haskell-bugs mailing list