[ghc-steering-committee] #380 GHC2021: Current status

Richard Eisenberg rae at richarde.dev
Thu Dec 3 16:32:16 UTC 2020



> On Dec 3, 2020, at 4:40 AM, Alejandro Serrano Mena <trupill at gmail.com> wrote:
> 
> - GADTs:
>   - Stable and well documented,
>   - Adding indices to types is one of the main reasons one would like to have MultiParamTypeClasses and TypeFamilies on,
>   - I find the GADT syntax much nicer (but this is an extremely personal choice.)

I voted against GADTs and am not yet inspired to change that vote: GADTs cause trouble for type inference. For example:

> data T a where
>   MkT :: Int -> T a
> 
> foo (MkT x) = x

GHC can infer that foo :: T a -> Int.

But if I change this to

> data T a where
>   MkT :: Int -> T Int
> 
> foo (MkT x) = x

(where T is now a GADT) GHC can no longer infer my type. It complains about untouchable variables. This is a case of a "bad failure mode", where a simple error in input can lead to a very complicated error message in output. I thus think that users should knowledgeably opt into GADTs. Maybe if we had a much gentler error message in place here, I could be convinced otherwise. But, for now:

Vote against GADTs!

Richard

PS: A counterpoint is RankNTypes, which I voted for. It would be hard to accidentally write a higher-rank type, and I find the error messages that arise are much clearer. Yes, it's an advanced feature, but one that is appropriately (in my opinion) gated in the code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20201203/d04225a5/attachment.html>


More information about the ghc-steering-committee mailing list