Frege / frege-repl

Frege REPL
78 stars 17 forks source link

Trouble with infix operators #16

Closed Ingo60 closed 9 years ago

Ingo60 commented 9 years ago

Here is todays session:

ingo@ibinti:~/Frege/frege$ repl
Welcome to Frege 3.21.586-g026e8d7 (Oracle Corporation OpenJDK Server VM, 1.7.0_65)

frege> (x³) = x^3   -- gives a reasonable answer
[ERROR: 3]: unexpected '³' while trying to parse unary expression

frege> infix 1 `³`    -- oops, forgot the infix

frege> (x³) = x^3   -- yay! now it works
function ³ :: Num α => α -> α

frege> (3³)         -- what is 3 cubed?
[ERROR: 4]: unexpected '}' while trying to parse left hand side of a
function or pattern binding
[ERROR: 4]: syntax error on end of file

frege> id (3³)      -- avoid ( at beginning  
[ERROR: 4]: unexpected '}' while trying to parse left hand side of a
function or pattern binding
[ERROR: 4]: syntax error on end of file

frege> map (³) [1..10]  
[ERROR: 4]: unexpected '}' while trying to parse left hand side of a
function or pattern binding
[ERROR: 4]: syntax error on end of file

frege> map (`³`) [1..10]     -- works, but ...
[1,8,27,64,125,216,343,512,729,1000]

Turns out the repl doesn't like the new operator at all - except, for what reason ever, when defining (x³) If I reuse a prelude operator, like ~ this all does work fine.

Note: operator recognition and parsing will be different from 3.22.xxx on, so if this is not a simple fix, just let it be how it is.

mmhelloworld commented 9 years ago

Thanks Ingo for reporting this bug with detailed information. I have now fixed this issue.

Both the command line REPL and the online REPL are updated and released / deployed.

Ingo60 commented 9 years ago

Thanks for fixing in such a short time.