alpaca-lang / alpaca

Functional programming inspired by ML for the Erlang VM
Other
1.44k stars 48 forks source link

Function parsing as incorrect arity with ADT as first arg #231

Closed lpil closed 6 years ago

lpil commented 6 years ago

Given there is a function assert.equal/2 defined

And option is defined like so:

type option 'a = Some 'a | None

If this code is written:

assert.equal None (flatMap f None)

It fails due to there being no function assert.equal/1

If the None is surrounded in parens it compiles.

assert.equal (None) (flatMap f None)
j14159 commented 6 years ago

At the moment this is unfortunate but expected behaviour; a type constructor always consumes the immediately following argument as part of AST construction. I think fixing this will require the typer to modify the AST or some other sort of iterative back-and-forth process with the typer (full disclosure: I haven't thought through this properly yet ;) )

To be clear: I think this would be good to fix, just difficult in the immediate term :) (so please don't close this, let's use it for further discussion as ideas come up)

j14159 commented 6 years ago

I'm going to close this for now as the fixes associated with #229 should make this clearer.

Longer-term it might be nice to do some type-directed re-interpretation of the AST but I'm not sure I want to go down that road just yet.