Skip to content

Possible to implement something like Haskell's syntax for writing arbitrary / custom infix functions in user space? #1675

Closed Answered by msujew
ym-han asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ym-han,

I think that should be possible purely by implementing additional parser rules. Kind of similar to the arithmetics example, you would have a new kind of expression:

Addition infers Expression:
Multiplication ({infer BinaryExpression.left=current} operator=('+' | '-') right=Multiplication)*;

InfixFunctionCallExpression infers Expression: 
  Multiplication 
  ({infer InfixFunctionCallExpression.left=current} 
    // The "operator" is actually a reference to a function
    operator=[Function:BacktickString] 
    right=Multiplication
  )*;

terminal BacktickString…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ym-han
Comment options

Answer selected by ym-han
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants