#1835: Provide information of the instance environment
--------------------------------+-------------------------------------------
Reporter: guest | Owner:
Type: feature request | Status: new
Priority: normal | Component: Template Haskell
Version: 6.8.1 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
--------------------------------+-------------------------------------------
This feature request was brought up in [1].
Right now TH doesn't have access to the instance environment of the
typechecker. Thus, it's impossible to check whether a class instance
exists for certain type, making impossible to guarantee the generation of
correct code in some cases.
For example, that happens when, for a justified reason, the function to be
spliced takes a variable Name as argument and not a value. There is no way
to force a class constraint on names nor a way to check whether the
variable type (obtained with reify) is an instance of a certain class. If
the generated code makes use of any
class function, its possible to generate incorrect code.
I suggest adding a function similar to this one:
{{{
isClassInstance :: Name -- ^ Class name
-> Type -- ^ Type to check
-> Q Bool
}}}
Another option would be extending ClassI to provide the list of instances
of a class and code 'isClassInstance' using that information.
[1] http://www.haskell.org/pipermail/template-
haskell/2007-November/000645.html
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1835>
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