[GHC] #15674: GADT's displayed type is misleading

GHC ghc-devs at haskell.org
Tue Sep 25 14:22:46 UTC 2018


#15674: GADT's displayed type is misleading
-------------------------------------+-------------------------------------
        Reporter:  AntC              |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.6.1-beta1
      Resolution:                    |             Keywords:
Operating System:  Windows           |         Architecture:  x86_64
 Type of failure:  Poor/confusing    |  (amd64)
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 Replying to [comment:2 AntC]:
 > (It's to do with pattern matching/deconstructing, rather than applying
 them as functions/constructing.)

 Precisely.

 > So ''prima facie'' `MkDF, MkDG`'s types are the same; `MkDG2`'s is
 different.

 This is true.

 > But actually `MkDG` is the same as `MkDG2`.

 In most contexts, yes. But you can say `MkDG2 @Int` while you can't do
 that with `MkDG`. Their types are subtly different.

 > (And setting `-fprint-explicit-foralls` doesn't explicitly show the
 `forall` in `MkDG`, although it does in `MkDG2`.

 There is no `forall` in `MkDG`, which doesn't quantify over any variables.

 > But `MkDG2`'s decl doesn't have an explicit `forall`, neither do I need
 `-XExplicitForAll` to compile it -- that's not implied by `-XGADTs`,
 surprisingly.)

 Your code does not contain an explicit `forall` in `MkDG2`. It contains an
 implicit one, implied by the presence of the type variable `a`.

 > > Does that help?
 > >
 > > Perhaps `:t` should behave precisely like `:i` if it is given a single
 identifier as its argument.  That would be non-uniform and ad-hoc, but
 perhaps useful in practice.

 But that would be non-uniform and ad-hoc. :)

 `:type <expr>` gives you the type that is assigned to `it` if you had `let
 it = <expr>`. It's a uniform rule that always works.

 >
 > Usually if I'm having trouble from error messages to do with
 "untouchable" or "rigid", it's `:t` I go to. I just have to kick myself to
 go to `:i`. But even the type signature showing in `:i` is misleading.
 Perhaps: if `<name>` is a data constructor, and not a H98 constructor, and
 `-fprint-explicit-foralls` is set, show the foralls explicitly?

 I'm not sure what `forall`s you're looking for. There isn't one in `MkDG`.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15674#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list