generation of type signatures for Accessors
Hey, I'm trying to modify data-accessor-template 'deriveAccessors' to generate type signatures so -Wall doesn't complain.
data P = P { x_::Int, y_::String } $(deriveAccessors ''P) should generate x :: Accessor P Int ... y :: Accessor P String ... That seems pretty easy.
But
data P a = P { x_::a, y_::a } $(deriveAccessors ''P) should generate x :: forall a. T (P a) a ... y :: forall a. T (P a) a ...
I was able to write TH to generate code for the first situation, but it failed for the second, and I don't feel confident about writing TH that will work generally. How difficult is it?
Excerpts from brian's message of Tue Mar 24 03:22:51 +0100 2009:
Hey, I'm trying to modify data-accessor-template 'deriveAccessors' to generate type signatures so -Wall doesn't complain.
You should look at data-accessor-template-0.2.1 for solution then ;) -- Nicolas Pouillard
On Tuesday, 24.03.09 at 09:45, Nicolas Pouillard wrote:
Excerpts from brian's message of Tue Mar 24 03:22:51 +0100 2009:
Hey, I'm trying to modify data-accessor-template 'deriveAccessors' to generate type signatures so -Wall doesn't complain.
You should look at data-accessor-template-0.2.1 for solution then ;)
Well, Henning released 0.2.1 because of the patch I sent him. Various projects are breaking right now because I didn't know about the parameterized records thing. That's why I'm asking on the list.
Excerpts from brian's message of Tue Mar 24 18:22:17 +0100 2009:
On Tuesday, 24.03.09 at 09:45, Nicolas Pouillard wrote:
Excerpts from brian's message of Tue Mar 24 03:22:51 +0100 2009:
Hey, I'm trying to modify data-accessor-template 'deriveAccessors' to generate type signatures so -Wall doesn't complain.
You should look at data-accessor-template-0.2.1 for solution then ;)
Well, Henning released 0.2.1 because of the patch I sent him. Various projects are breaking right now because I didn't know about the parameterized records thing. That's why I'm asking on the list.
Ooops, I could have said something more useful then :) Basically one have to ask for the parameters of the type (`a' here). One then have to use these parameters to build a fully applied type (`P a' here), finally one must bind those type variables using a universal quantification (`forall a.' here). I attach a darcs patch that does exactly this. However I've only tested a few test cases. PS: I've put Henning in copy of this message. -- Nicolas Pouillard
On Tuesday, 24.03.09 at 23:26, Nicolas Pouillard wrote:
I attach a darcs patch that does exactly this. However I've only tested a few test cases.
Thank you very much for doing that, Nicolas. I verified that it fixes everything here and sent a unified diff to Henning. Hopefully this resolves the issue. Thanks again.
participants (2)
-
brian@lorf.org -
Nicolas Pouillard