operator sections
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
module ErrMsg
|
||||
|
||||
import Prelude
|
||||
|
||||
infixl 5 _$$_
|
||||
|
||||
_$$_ : Nat → (Nat → Nat) → Nat
|
||||
a $$ b = a + b a
|
||||
|
||||
-- Say something other than expected record
|
||||
-- Why do we get there? shouldn't the progress made by parseDef short circuit the <|>?
|
||||
blah : Nat → Nat
|
||||
blah x = x $$ $ \ y => y
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
*** Process tests/ErrMsg.newt
|
||||
module Prelude
|
||||
module ErrMsg
|
||||
ERROR at tests/ErrMsg.newt:13:15--13:16: trailing operator
|
||||
|
||||
Compile failed
|
||||
20
tests/Section.newt
Normal file
20
tests/Section.newt
Normal file
@@ -0,0 +1,20 @@
|
||||
module Section
|
||||
|
||||
import Prelude
|
||||
|
||||
-- got infix in prefix position
|
||||
add : Int → Int → Int
|
||||
add = (+)
|
||||
|
||||
add2 : Int → Int
|
||||
add2 = (+ 2)
|
||||
|
||||
-- trailing operator
|
||||
add2' : Int → Int
|
||||
add2' = (2 +)
|
||||
|
||||
main : IO Unit
|
||||
main = do
|
||||
printLn $ (+) 2 3
|
||||
printLn $ (+ 3) 2
|
||||
printLn $ (2 +) 3
|
||||
3
tests/Section.newt.golden
Normal file
3
tests/Section.newt.golden
Normal file
@@ -0,0 +1,3 @@
|
||||
5
|
||||
5
|
||||
5
|
||||
13
tests/TrailDollar.newt
Normal file
13
tests/TrailDollar.newt
Normal file
@@ -0,0 +1,13 @@
|
||||
module TrailDollar
|
||||
|
||||
import Prelude
|
||||
|
||||
infixl 5 _$$_
|
||||
|
||||
_$$_ : Nat → (Nat → Nat) → Nat
|
||||
a $$ b = a + b a
|
||||
|
||||
-- Previously this didn't parse, but it does with operator section support.
|
||||
blah : Nat → Nat
|
||||
blah x = x $$ $ \ y => y
|
||||
|
||||
Reference in New Issue
Block a user