[GHC] #7066: isInstance does not work for compound types

GHC ghc-devs at haskell.org
Tue Apr 15 12:03:46 UTC 2014


#7066: isInstance does not work for compound types
-------------------------------------+------------------------------------
        Reporter:  edsko             |            Owner:  simonpj
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:  7.8.3
       Component:  Template Haskell  |          Version:  7.4.2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by simonpj):

 Hmm:

  * Are you making the case for an actual change in the behaviour of the
 current TH operations?  The current `reifyInstances` is deliberately
 primitive (a one-level lookup) so that other stuff can be built on top.
 Or are you asking for some new functions in the `Quasi` monad; or new
 functions in the `template-haskell` library?

  * It would help a lot to be clear precisely what the behaviour is
 supposed to be when the types concerned contain type variables.  Currently
 `reifyInstances` returns all the instance whose heads unify with the
 specified constraint.  I've looked at your code and it's not clear to me
 exactly what it does.  Could you write a specification?

  * I think it's arguable that what you ''really'' want is something like
 {{{
 isInstance :: Cxt -> Name -> [Type] -> Q Bool
 }}}
  return `True` if the constraint `(C tys)` is provable from the specifed
 context.  For example, you could ask, say `isIntance [Show a, Num a] Foo
 [Maybe a]`, to ask whether you can prove `(Foo (Maybe a))` from `(Show a,
 Num a)`.  For ground types you could give the empty `Cxt`.

 Simon

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


More information about the ghc-tickets mailing list