dex-lang icon indicating copy to clipboard operation
dex-lang copied to clipboard

Can Dex actually allow question marks in array sizes?

Open axch opened this issue 2 years ago • 3 comments

I tried to define a function specialized to a flat array with an anonymous (unknown) size, like so:

def fin_mean (xs: (Fin _)=>Float) : Float =
  mean xs

and I got this:

Not implemented:
Please report this at github.com/google-research/dex-lang/issues

Type inference of this program requires delayed interface resolution

def fin_mean (xs: (Fin _)=>Float) : Float =
                   ^^^^^^^^^^^^^

This doesn't block anything for me, because it's easy enough to just add the implicit Nat argument to serve as a name for the size, but the gap seems unaesthetic.

axch avatar Jun 09 '22 18:06 axch

Well, a type annotation is an expression, so whenever you say _ it means "this can be inferred". But in this case it can't, because there's nothing to provide the size of xs! I read your issue as expecting _ to automatically make the function polymorphic, but _ never introduces any more binders/polymorphism!

apaszke avatar Jun 13 '22 11:06 apaszke

Hm. Then "not implemented" is probably not a good error message.

axch avatar Jun 13 '22 13:06 axch

I agree it's not good. But putting an extra inference variable in there does hit a not implemented case in inference, so it's also true. We used to support this before safer names, but not anymore.

apaszke avatar Jun 14 '22 10:06 apaszke