A bidirectional typechecking puzzle

37 points by Gabriella439


icefox

Congrats on turning the Complete And Easy paper into something that functions! And a good example of where bidi's greedy nature can cause subtle issues. (Not a knock against it, inference always has issues, the best you can do is decide which ones you want.) And also why, IMO, subtyping and type coercion are usually anti-features.

If you treat the data as a source of truth for the types, then you're really not going to be able to check if the data is malformed or not. You'll just get incorrect types when there's a mistake rather than an informative error, as demonstrated. Though now that I read again you're the creator of Dhall (<3) so you probably know more about this than me... Now that I think more, being able to take a bunch of data and generate a schema for it is interesting idea that deserves research. Just not sure I would call it "type checking", since types are kiiiiinda assumed to be prescriptive, not descriptive...

isuffix

I don't think I really understand why you're not just rejecting f? It's accessing a field of a record that has a type which can never have that field, this is almost certainly a bug in the program that I'd want a type checker to tell me about.

I think it differs from the authority example because the type of port isn't missing, but Optional. I don't see how rejecting missing fields requires rejecting optional fields. In particular, you can also coerce { domain: "google.com" } to the value { domain: "google.com", port: null } since you're already coercing values based on types.

thunderseethe

The immediate thought that jumps to my mind is: row types solve this! I imagine you considered that already. Do row types fall over here because of how they interact with subtyping?