Two arguments are not two arguments according to the type checker
|Reported by:||josef||Owned by:|
|Component:||Compiler (Type checker)||Version:||7.0.3|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
I got a very strange type error message from GHC today. I've inserted it at the end of this message. It is misleading because it complains that a "lambda expression [...] has two arguments, but its type [...] has only two". Now, I know that the code contains type errors but the error message could be more helpful.
The code fragment which provokes this message looks as follows:
let writeElement = case ty of Core.FloatType -> \ix element -> tell [loc :!: ix := LitF element]
The Core.FloatType constructor is part of a GADT, the case ought to refine the type of element to Float. I don't know if that's what's tripping GHC up. The actual error has to do with the type of ix which should be of type Expr but the function writeElement is applied to an argument of type Integer.
The error message:
Couldn't match type `Expr' with `Integer' The lambda expression `\ ix element -> tell ...' has two arguments, but its type `Integer -> b0 -> RWST () [Prog] Integer Data.Functor.Identity.Identity c0' has only two In the expression: \ ix element -> tell [loc :!: ix := LitF element] In a case alternative: Core.FloatType -> \ ix element -> tell [loc :!: ix := LitF element]