Open rrdelaney opened 7 years ago
Hey, new crop of issues! I'd like to give this a go.
Awesome! You'll probably want to look around here for implementing them 😄
Back after a little research. Just to confirm approach, I'm not sure how to implement some classes of type bounds with current tools; it seems like we'd drop some of them (i.e. just replace the type params with refs to their bounds), or we need some upstream changes.
extending primitives like string
doesn't seem possible, since we can't create direct disjoints of primitives like 'foo'|'bar'
, meaning that any type we create from said disjoints won't be detectable as originating from string
, in BS, will it?
depending on the disposition of #26, we can't meaningfully extend our (currently closed) object types, can we? I.e., aren't types bounded by closed objects just effectively parameterized by those exact object types, since you wouldn't be able to pass any more or fewer fields than they're declared with, since ocaml doesn't have (AFAIK!) any kind of object extension?
As it stands, it seems like I might mostly end up mostly declaring class-hierarchy bounds. Does that line up with your plans? Alternately, if #26 seems right, I could implement that (and add support for exact types, if anyone ever uses them :P).
EDIT: It looks like this last bit should wait for #25, since we'll need to know how to encode class inheritance before requiring it! I assume it'll involve open objects, but just in case...
Flow type definitions can give bounds to type parameters. We'd like to support them because they're giving us about 17 errors when compiling the FlowTyped test suite.
Blog post about type parameter bounds in Flow: https://flow.org/blog/2015/03/12/Bounded-Polymorphism/