grain
grain copied to clipboard
Parser disallows defining <<< as an operator
When trying to define the <<<
operator in some code (below), the parser fails with this error:
Syntax error after '<<' and before '<'. Expected
)
to complete the pattern.
let (<<<) = (p, q, state) => {
let x = p(state)
q(state): Void
x
}
It also disallows (|||)
Unlike OCaml, Grain only supports operators defined by the language (pending documentation here: https://deploy-preview-301--grain-lang.netlify.app/docs/reference/lexical_structure/operators) and not arbitrary operators, so this is expected.
@phated are you suggesting we allow defining infix operators with a certain syntax? Here's what OCaml supports: https://caml.inria.fr/pub/docs/manual-caml-light/node4.9.html
I think we should do something about allowing any combination of those characters in bindings. Even if it's only between parens. It's really weird/unexpected behavior that I can define bindings that overwrite internal operators, but can't use those characters in any other way.