Hi,
Could someone please explain to me why the
following error message happen:
When I load the following code into GHC I get an
error message:
code:
---------------------------------------------------------------------------------------------------
data AParser String = AP
{apapply::([String]->[(String,[String])])}
instance Monad AParser where
return v = AP (\inp -> [(v,inp)]) (AP p) >>= f = AP (\inp -> concat [ apapply (f v) inp1 | (v,inp1) <- p inp]) ---------------------------------------------------------------------------------------------------
error:
---------------------------------------------------------------------------------------------------
Inferred type is less polymorphic than
expected
Quantified type variable `b' is unified with another quantified type variable `a' When trying to generalise the type inferred for `>>=' Signature type: forall a1 b1. AParser a1 -> (a1 -> AParser b1) -> AParser b1 Type to generalise: forall a1 b1. AParser a1 -> (a1 -> AParser b1) -> AParser b1 In the instance declaration for `Monad AParser' Failed, modules loaded: none. ---------------------------------------------------------------------------------------------------
But when I create the type synonym
type Stack = [String]
data AParser String = AP {apapply::(Stack -> [(String,Stack)])}
and use Stack instead of [String], GHC does not complain???
Thanks. Mansour. |
- RE: GHC Error Message. Mansour Al-Mutairi
- RE: GHC Error Message. Simon Peyton-Jones