[GHC] #15674: GADT's displayed type is misleading
GHC
ghc-devs at haskell.org
Tue Sep 25 13:55:21 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 AntC):
Replying to [comment:1 simonpj]:
Thank you Simon.
> `:type <expr>` tells you the type of the expression `<expr>`, where
`<expr>` can be any old expression, not just a single identifier.
>
Yes. So you're saying those three data constructors are at the same type,
considered as expressions(?) What is it about their typedness that
explains the observable difference in behaviour wrt the functions? (It's
to do with pattern matching/deconstructing, rather than applying them as
functions/constructing.)
> On the other hand `:info <name>` gives you information about the
declaration of the entity `<name>`.
Yes, `:info` more or less shows the code that declares `<name>`.
> And indeed `:info MkDF`, `:info MkDG` and `:info MkDG2` give you the
info that I think you want.
Hmm. `:info` still shows `MkDF :: Int -> DF Int`, `MkDG :: Int -> DG Int`.
It does show `MkDG2 :: (a ~ Int) => a -> DG a` or even `MkDG2 :: forall a.
(a ~ Int) => a -> DG a`.
So ''prima facie'' `MkDF, MkDG`'s types are the same; `MkDG2`'s is
different. But actually `MkDG` is the same as `MkDG2`. (And setting
`-fprint-explicit-foralls` doesn't explicitly show the `forall` in `MkDG`,
although it does in `MkDG2`. 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.)
> This works if the constructors are imported from a library that you
can't (easily) see.
>
Ok.
> 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.
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?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15674#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list