Suggesting RankNTypes for ill-formed types

Karolina Drobnik karolinadrobnik at gmail.com
Thu Aug 11 17:30:41 UTC 2016


Hello everyone,

I am working on my first ticket (#11669, linked below)
and I have some doubts after a little bit of hacking.

There was a hint that an error message should be
changed from the one suggesting RankNTypes to ExplicitForall.
In my opinion it would be quite confusing for the user, especially where
the type is ill-formed. A plain parse error should be shown here.

It is clear that it should be done in such a way after turning on one
of the extensions, but what about the situation where proposed
fix (suggesting RankNTypes/ExplicitForall) won't work?
We should be able to distinguish ill-formed type from the correct one,
even before the extension activation. To be honest - I don't know how to do
it.

Additionally, I am not sure if we can assume that an user wants
to use arbitrary rank (which implies ExplicitForall) or just a forall
keyword.
I am for the second one, but it is just my assumption.

And the last minor thing - a type formed in this way also rises an error
suggesting using RankNTypes (as we know that wouldn't solve the problem):

f :: a. -> Int
f = undefined

Maybe we could treat it as a typo (simple parse error) and propose
an extension activation only when forall was parsed earlier?
That could be tricky.

I'd appreciate some thoughts on this issue because I felt a bit lost
after digging around the parser.

Best regards,

Karolina
---------------------------------------------------------
#11669 - https://ghc.haskell.org/trac/ghc/ticket/11669
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160811/53932e23/attachment.html>


More information about the ghc-devs mailing list