gren-lang / gren-lang/compiler

prefix binary operations → curry-able functions

Open
#79 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
503
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Using an operator's prefix notation is unintuitive and prone to errors:

Just 3 |> Maybe.map ((-) 3)
--> Just 0

Proposal: remove (symbol) syntax and prefix binary operations in favor of actual functions:

  • (^) n expn |> toPower exp
  • (/) n divn |> divideBy div
  • (//) n divn |> Int.divideBy div
  • (*) n muln |> multiplyBy mul
  • (-) n subn |> subtract sub
  • (+) a bb |> add a
  • ...
  • (||) a ba |> and b
  • (&&) bool otherbool |> or other
  • min a ba |> atMost b
  • max a ba |> atLeast b
  • (<) a ba |> isBelow b
  • (<=) a ba |> isAtMost b
  • (>=) a ba |> isAtLeast b
  • (>) a ba |> isAbove b
  • (++) init tail, .append init tailinit |> .append tail
  • (::) element listlist |> cons element
  • (<|) → remove? apply?
  • (|>) → remove? eat/feed/feedWith/with?
  • (>>) → remove?
  • (<<) → remove? over/overTo/to/then/thenTo/compose/furthermore/furtherTo?

including parser operators (replaced by |> skip, |> grab, ...).

My secret hope is that just like %, which was removed in favor of modBy & remainderBy,
conventions will develop abandoning, for example

  • &&, ||, min, max, unary -, ^, all parser operators
  • init ++ (middle |> operation) ++ tail
    • in favor of init |> append (middle |> operation) |> append tail and sometimes [ init, middle |> operation, tail ] |> concat

(I'm not opposed to removing all listed and more)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name files, tests, or entry points. Start by surveying the compiler's parser and operator handling, then clarify which operators and replacement functions are in scope with maintainers. Done would require an agreed migration scope and corresponding compiler behavior, including parser operators.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.