[GHC] #9701: GADTs not specialized properly

GHC ghc-devs at haskell.org
Mon Oct 20 08:04:25 UTC 2014


#9701: GADTs not specialized properly
-------------------------------------+-------------------------------------
              Reporter:  dfeuer      |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.9
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:  Runtime     |       Blocked By:
  performance bug                    |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Implicit parameters. They are indeed treated specially.  In particular,
 the example in comment:10 for implicit parameters would look like this:
 {{{
 data SillyIP a where Silly :: ?plus::(a->a->a) => a -> Silly a

 -- Inferred type
 --   double :: (?plus :: Int -> Int -> Int) => Int -> Int
 double n = ?plus n (n::Int)

 oops :: Silly Int
 oops (Silly x) = double x
 }}}
 There are no top-level implicit parameters, so `double`'s inferred type is
 as shown, and it'll pick up `plus` from the `Silly` pattern match.

 Reverting to the main thread, I'm not sure where this discussion is going.
 The base assumption is if multiple type-class instances match (e.g. from
 two enclosing pattern matches, comment:2, or from an enclosing patten-
 match and the top level) then you are on terribly thin ice is you want to
 predict which one will be chosen. They are all supposed to have the same
 value, and if they don't then, well, the ice is thin.

 One could try to thicken up the ice here, but it's all tangled up with the
 scoping of instances, overlapping instances, incoherent instances etc...
 My take on this: brain cycles are more productively invested elsewhere.

 Simon

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


More information about the ghc-tickets mailing list