Determining if an instance is provided by the environment
Edward Z. Yang
ezyang at mit.edu
Thu May 5 23:20:46 UTC 2016
Hello all,
Suppose I have a ClsInst from typechecking the following instance
declaration:
instance Show [Char] -- i.e. String
I'd now like to answer the question: "Is this instance 'provided'
by the instance environment?" For example, this instance is provided
given that I have these two instances in the environment:
instance Show a => Show [a] -- (1)
instance Show Char -- (2)
However, if I have just instance (1) in the environment, it's not
provided (and if you tried to use show "foo", you'd get the error
that Char is not an instance of Show.)
Is there are convenient way to do this from TcM? With 'tcMatchTys'
and I can easily test if there is some instance in the environment
which *matches* my instance head (e.g., Show [a] matches Show [Char])
but this doesn't tell me if all the resulting constraints are
solvable.
Thanks,
Edward
More information about the ghc-devs
mailing list