Find constraints over type
Simon Peyton Jones
simonpj at microsoft.com
Thu Jan 16 18:47:36 UTC 2020
There is definitely no pure way to get from ‘a’ to its constraints.
* It is far from clear what “its constraints” are. Is (C a b) such a constraint? C [a] b? What about superclasses?
* Constraints vary depending on where you are. GADT matches can bring into scope extra constraints on existing type variables.
So as Ben says, to give a sensible response you’ll need to explain more about your goal
From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Alejandro Serrano Mena
Sent: 16 January 2020 16:19
To: GHC developers <ghc-devs at haskell.org>
Subject: Find constraints over type
Dear GHC devs,
I am trying to figure out a way to obtain the constraints that hold over a type. Let me give you an example: suppose that I write the following function:
f :: Eq a => [a] -> Bool
f xs = xs == 
If I ask for the type of the Var ' xs', I get back '[a]'. This is correct, but I am missing the crucial information that '[a]' must be Eq.
Is there an easy way to get it? It seems that 'varType' doesn't give me enough information.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs