trill-lang / trill

A type safe, compiled language inspired by (and written in) Swift
MIT License
275 stars 15 forks source link

Start Solving For Type Variables (Locally) #43

Closed CodaFi closed 7 years ago

CodaFi commented 7 years ago

Adds two new forms of shorthand for closures. This necessitated modeling type variables and starting the most rudimentary of solvers in the TypeChecker.

YOUR PARSER MAKES TYPE VARIABLES, I HOPE YOU'RE HAPPY

CodaFi commented 7 years ago

Hm, so this removes the ability to "coerce".

segiddins commented 7 years ago

Can you also add an example to demonstrate what this will allow?

segiddins commented 7 years ago

Pardon my ignorance, but what's the benefit of propagating the canonical types directly?

CodaFi commented 7 years ago

Propagating sugar down the context is better for debugging, but means every access to the type needs to be guarded by a canonicalize call. Really, it's a modeling problem. We should be able to retain annotated types and all their sugar, solve constraint systems with canonical types, then apply and get rid of the propagation call.

harlanhaskins commented 7 years ago

I actually think we should remove that. It makes type checker errors worse by stripping the sugar in diagnostics.

harlanhaskins commented 7 years ago

I eventually want to be able to say:

error: cannot convert value of type 'Foo' (aka 'Array<(Int, String)>') to type 'Bar' (aka String)
CodaFi commented 7 years ago

Starting work on the solver. We're going OutsideIn light (no GADTs, no existentials, no generalization).

CodaFi commented 7 years ago

@segiddins I appreciate the review, but nothing here works yet!

segiddins commented 7 years ago

Understood, just trying to understand it 😅