Opened 2 years ago

Closed 2 years ago

#5577 closed bug (invalid)

Two arguments are not two arguments according to the type checker

Reported by: josef Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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]

Change History (2)

comment:1 Changed 2 years ago by simonpj

  • Status changed from new to infoneeded

Happy to help, but I need to reproduce it. Can you cut it down to a small example? Should not be hard... usually giving defns like f :: <type>; f = error "uk" to variables that don't play an important role will do the job.

Thanks

Simon

comment:2 Changed 2 years ago by igloo

  • Resolution set to invalid
  • Status changed from infoneeded to closed

No response from submitter, so closing.

Note: See TracTickets for help on using tickets.