#1835: Provide information of the instance environment
-------------------------------+--------------------------------------------
Reporter: guest | Owner: igloo
Type: feature request | Status: patch
Priority: normal | Milestone: _|_
Component: Template Haskell | Version: 6.8.1
Resolution: | Keywords:
Testcase: | Blockedby:
Difficulty: Unknown | Os: Unknown/Multiple
Blocking: | Architecture: Unknown/Multiple
Failure: None/Unknown |
-------------------------------+--------------------------------------------
Comment(by simonpj):
Thanks for doing this work. We will definitely put this in GHC 6.14.
Apart from the implementation we just need to check that there is
consensus about the ''design''. You propose:
* Extending the `Quasi` monad to have
{{{
class (Monad m, Functor m) => Quasi m where
...
qReify :: Name -> m Info
qIsClassInstance :: Name -> [Type] -> m Bool
isClassInstance :: Name -> [Type] -> Q Bool
isClassInstance n ts = Q (qIsClassInstance n ts)
}}}
* Extending the info you get back when reifying a `Class`, by adding its
instances:
{{{
data Dec = ...
| ClassI Dec [([TyVarBndr],Cxt,[Type])]
}}}
Some random thoughts
* In principle, I suppose that `isClassInstance` isn't really necessary:
you could reify the class and search the list yourself. But I can see
that it's convenient.
* Currently `isClassInstance` returns `True` if any instances match, even
if they overlap etc. Might you want to know more?
I'd like to see if the proposed design meets the needs of other Template
Haskell users. Any comments from any other TH users? Even just "yea" would
be good to know.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1835#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs