[jhc] explanation of FrontEnd.KindInfer.constrain

John Meacham john at repetae.net
Wed Mar 19 19:09:56 EDT 2008


On Wed, Mar 19, 2008 at 06:55:29PM -0400, Samuel Bronson wrote:
> > 2. an actual '?' or '??' is sneaking in as a kind when it should have
> > been turned into a freshly instantiated kind variable with a ? or ??
> > constraint as appropriate.
> 
> Where is this process supposed to happen? I didn't see anything that
> looked like that in KindInfer, and I don't think it could be anywhere
> else, since the monad it would need to work in is only available in
> that module...

Well, that's the thing, I never implemented users being able to use '?'
and '??' directly, so I never needed to implement it for user defined
kinds.

where it currently happens is in KindInfer in all the calls to
'newKindVar' in kiType. notice that when you have an unboxed tuple for
instance, its subkinds are declared with ?? constraints. likewise for a
function call and so forth.

so what needs to happen for user defined ones to work is for
'lookupKind' to create a freshly instantiated version of the constructor
with no literal ? or ??'s in it, just constrained kindvars.

note that this brings up intruging possibilities. like

data Complex (a :: ??) = a :+: a

notice you can now have data structures with polymorphic unboxed values
in them! so your complex Float can actually have two unboxed floats next
to each other. but this raises several other issues when it comes to
actaully generating code for that.

note also that the primitive pre-defined tArrow in DataConstructors has
the wrong type. this is a known bug but the current workarounds are okay
for now and it will be a fairly complicated one to fix.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the jhc mailing list