Determining if an instance is provided by the environment
Simon Peyton Jones
simonpj at microsoft.com
Fri May 6 09:05:31 UTC 2016
You probably want a variant on TcDeriv.simplifyDeriv, shorn of its complex error reporting.
Simon
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of
| Edward Z. Yang
| Sent: 06 May 2016 00:21
| To: ghc-devs <ghc-devs at haskell.org>
| Subject: Determining if an instance is provided by the environment
|
| 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
| _______________________________________________
| ghc-devs mailing list
| ghc-devs at haskell.org
| https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha
| skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc-
| devs&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c8c304d9b355244c6
| ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=iWdrnb6hC
| 8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d
More information about the ghc-devs
mailing list