Skip to content

Infix operators using Sweet #72

@d-plaindoux

Description

@d-plaindoux

Expressiveness can be increased using infix operators.

p1 <*> p2    // == p1.then(p2)
p1 <|> p2    // == p1.or(p2)
p1 >>= p2    // == p1.flatmap(p2)
p1 || p2     // == p1.chain(p2)

This can be achieved using Sweet.JS meta language.

operator <*> left 1 = (left, right) => #`${left}.then(${right})`;
operator <|> left 1 = (left, right) => #`${left}.or(${right})`;
operator >>= left 1 = (left, right) => #`${left}.flatmap(${right})`;
operator || left 1  = (left, right) => #`${left}.chain(${right})`;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions