degory / ghul

compiler for the ghūl programming language
https://ghul.dev
GNU Affero General Public License v3.0
4 stars 0 forks source link

Consistently apply type implications #1174

Open degory opened 7 months ago

degory commented 7 months ago

Type inference in ghūl works in two directions:

  1. Right to left, inner expressions to outer expressions ('type inference')
  2. Left to right, outer expressions to inner expressions ('type implication' / 'type constraints')

There are scenarios where these mechanisms could be applied but currently aren't and there are two different implementations of the second mechanism that should be unified, because currently type information doesn't propagate if the producer is using one implementation and the consumer expects the other

Producers of type implications:

Consumers of type implications:

[1, 2, ,3 ,4] | .filter(n => n % 2 ==0) 

Producers of type constraints:

Consumers of type constraints:

Type constraints and type implications should be unified:

Type constraints could be produced in additional places: