Enable TypeHoles by default?

Krzysztof Gogolewski krz.gogolewski at gmail.com
Sun Jan 12 22:56:15 UTC 2014


Hello,

I propose to enable -XTypeHoles in GHC by default.

Unlike other -X* flags, holes do not really change meaning of the program,
they only change error messages. Instead of "_x not in scope", we
effectively get "_x not in scope, its expected type is a -> a". You get it
only if you precede the identifier not in scope with underscore, so in some
sense you declare the intention of using holes.

Two possible issues:

(a) If you use -fdefer-type-errors, then a program might compile, while
previously it did not. However, we should facilitate compiling with
defer-type-errors, so I don't think this is a disadvantage.

(b) The identifier _ becomes both a pattern and a hole by default, which
might confuse new users.
Reply: I have never seen anyone ask why code such as "Just _ -> _" does not
work.

IMO the productivity boost by having holes by default outweighs those two
objections. I am open to hearing any other possible issues others might
find.

The change is trivial implementation-wise; add Opt_TypeHoles to the list in
languageExtensions Nothing in DynFlags.

-KG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140112/6107749e/attachment.html>


More information about the ghc-devs mailing list