> > : Marc.hs:7:
> > : Cannot unify the type-signature variable `p' with the
> type `[]'
> > : Expected type: [a]
> > : Inferred type: p a1
> > : In the first argument of `ci', namely `a'
> > : In the scrutinee of a case expression: ci a
> >
> > Great!
>
> But shouldn't the expected type and inferred type be reversed?
Actually, no. The rationale (and implementation) is this:
* the "expected type" describes the context
* the "inferred type" describes the term
class C p a where
ci :: p a -> p a
f :: (C p a) => (p a) -> (p a)
f a = case ci a of
[] -> a
Here, the context of "ci a" is a case expression that has
list-typed patterns. So we *infer* the type
ci a :: p a1
but the list context disagrees.
I don't see how to swap the roles without giving even more confusion.
Simon
RE: Proposal for error message improvement
Simon Peyton-Jones Thu, 22 Apr 1999 15:21:48 +0200 (MET DST)
- RE: Proposal for error message improvement Simon Peyton-Jones
- Re: Proposal for error message improvement Marc van Dongen
- RE: Proposal for error message improvement Simon Marlow
- Re: Proposal for error message improvement Marc van Dongen
- RE: Proposal for error message improvement Simon Peyton-Jones
- RE: Proposal for error message improvement Simon Marlow
