change syntax for javascript code literals
This commit is contained in:
@@ -3,8 +3,8 @@ module Auto
|
||||
ptype String
|
||||
ptype Int
|
||||
|
||||
pfunc i2s : Int -> String := "(i) => ''+i"
|
||||
pfunc _++_ : String -> String -> String := "(a,b) => a + b"
|
||||
pfunc i2s : Int -> String := `(i) => ''+i`
|
||||
pfunc _++_ : String -> String -> String := `(a,b) => a + b`
|
||||
|
||||
infixl 4 _++_
|
||||
|
||||
@@ -21,7 +21,7 @@ showInt : Show Int
|
||||
showInt = MkShow i2s
|
||||
|
||||
ptype World
|
||||
pfunc log : {A : U} -> A -> World := "(_, a) => console.log(a)"
|
||||
pfunc log : {A : U} -> A -> World := `(_, a) => console.log(a)`
|
||||
|
||||
main : Int -> World
|
||||
main _ = log ("answer: " ++ show 42)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Auto2
|
||||
|
||||
ptype World
|
||||
pfunc log : {A : U} -> A -> World := "(_, a) => console.log(a)"
|
||||
pfunc log : {A : U} -> A -> World := `(_, a) => console.log(a)`
|
||||
|
||||
ptype Int
|
||||
pfunc i_plus : Int -> Int -> Int := "(x,y) => x + y"
|
||||
pfunc i_plus : Int -> Int -> Int := `(x,y) => x + y`
|
||||
|
||||
data Nat : U where
|
||||
Z : Nat
|
||||
|
||||
@@ -20,9 +20,9 @@ ptype JVoid
|
||||
|
||||
-- If we had a different quote here, we could tell vscode it's javascript.
|
||||
-- or actually just switch modes inside pfunc
|
||||
pfunc log : String -> JVoid := "(x) => console.log(x)"
|
||||
pfunc plus : Int -> Int -> Int := "(x,y) => x + y"
|
||||
pfunc _*_ : Int -> Int -> Int := "(x,y) => x * y"
|
||||
pfunc log : String -> JVoid := `(x) => console.log(x)`
|
||||
pfunc plus : Int -> Int -> Int := `(x,y) => x + y`
|
||||
pfunc _*_ : Int -> Int -> Int := `(x,y) => x * y`
|
||||
|
||||
-- We now have to clean JS identifiers
|
||||
_+_ : Int -> Int -> Int
|
||||
|
||||
@@ -10,7 +10,7 @@ _+_ : {A : U} {{_ : Plus A}} -> A -> A -> A
|
||||
_+_ {{MkPlus plus}} x y = plus x y
|
||||
|
||||
ptype Int
|
||||
pfunc plusInt : Int -> Int -> Int := "(x,y) => x + y"
|
||||
pfunc plusInt : Int -> Int -> Int := `(x,y) => x + y`
|
||||
|
||||
PlusInt : Plus Int
|
||||
PlusInt = MkPlus plusInt
|
||||
|
||||
@@ -7,7 +7,7 @@ module TestPrim
|
||||
ptype String
|
||||
ptype Int
|
||||
|
||||
pfunc strlen : String -> Int := "(x) => x.length()"
|
||||
pfunc strlen : String -> Int := `(x) => x.length()`
|
||||
|
||||
-- why is there an eta in here?
|
||||
foo : String -> Int
|
||||
@@ -16,12 +16,12 @@ foo = \ x => strlen x
|
||||
bar : String -> String -> Int
|
||||
bar = \ x y => strlen x
|
||||
|
||||
pfunc append : String -> String -> String := "(a,b) => a + b"
|
||||
pfunc append : String -> String -> String := `(a,b) => a + b`
|
||||
|
||||
blah : String
|
||||
blah = append "hello" "world"
|
||||
|
||||
pfunc plus : Int -> Int -> Int := "(a,b) => a + b"
|
||||
pfunc plus : Int -> Int -> Int := `(a,b) => a + b`
|
||||
|
||||
answer : Int
|
||||
answer = plus 40 2
|
||||
@@ -30,7 +30,7 @@ answer = plus 40 2
|
||||
|
||||
-- codegen test cases
|
||||
-- works, but two looks like () => (eta1) => (eta0) => one(eta1, eta0)
|
||||
pfunc one : Int -> Int -> Int := "(x,y) => x + y"
|
||||
pfunc one : Int -> Int -> Int := `(x,y) => x + y`
|
||||
|
||||
two : Int -> Int -> Int
|
||||
two = one
|
||||
|
||||
Reference in New Issue
Block a user