int add becomes +
This commit is contained in:
2
Makefile
2
Makefile
@@ -30,7 +30,7 @@ orig_test: build/exec/newt
|
|||||||
# New version
|
# New version
|
||||||
|
|
||||||
newt.js: ${SRCS}
|
newt.js: ${SRCS}
|
||||||
-rm build/*
|
-rm build/* >/dev/null
|
||||||
$(RUNJS) bootstrap/newt.js src/Main.newt -o newt.js
|
$(RUNJS) bootstrap/newt.js src/Main.newt -o newt.js
|
||||||
|
|
||||||
newt2.js: newt.js
|
newt2.js: newt.js
|
||||||
|
|||||||
2
TODO.md
2
TODO.md
@@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
- [ ] Increment row/col in printing, so vscode can click on compiler output
|
||||||
- [ ] Raw is duplicated between Lib.Syntax and Lib.Compile, but not detected
|
- [ ] Raw is duplicated between Lib.Syntax and Lib.Compile, but not detected
|
||||||
|
- Maybe add qualified names
|
||||||
- [ ] vscode - run newt when switching editors
|
- [ ] vscode - run newt when switching editors
|
||||||
- [ ] who calls X? We can only do this scoped to the current context for now. Someday whole source dir
|
- [ ] who calls X? We can only do this scoped to the current context for now. Someday whole source dir
|
||||||
- [ ] case split
|
- [ ] case split
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
## Todo items for the playground
|
## Todo items for the playground
|
||||||
|
|
||||||
|
- [ ] switch to oxlint (dependency reduction)
|
||||||
- [x] sample files
|
- [x] sample files
|
||||||
- [x] codemirror migration
|
- [x] codemirror migration
|
||||||
- [ ] make sample files available for import
|
- [ ] make sample files available for import
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ lamArity : Tm -> Nat
|
|||||||
lamArity (Lam _ _ _ _ t) = S (lamArity t)
|
lamArity (Lam _ _ _ _ t) = S (lamArity t)
|
||||||
lamArity _ = Z
|
lamArity _ = Z
|
||||||
|
|
||||||
|
compilePrimOp : String → List CExp → Maybe CExp
|
||||||
|
compilePrimOp "Prelude.addString" (x :: y :: Nil) = Just (CPrimOp "+" x y)
|
||||||
|
compilePrimOp "Prelude.addInt" (x :: y :: Nil) = Just (CPrimOp "+" x y)
|
||||||
|
compilePrimOp "Prelude.mulInt" (x :: y :: Nil) = Just (CPrimOp "*" x y)
|
||||||
|
compilePrimOp "Prelude.subInt" (x :: y :: Nil) = Just (CPrimOp "-" x y)
|
||||||
|
compilePrimOp "Prelude.divInt" (x :: y :: Nil) = Just (CPrimOp "|" (CPrimOp "/" x y) (CLit $ LInt 0))
|
||||||
|
compilePrimOp _ _ = Nothing
|
||||||
|
|
||||||
-- This is how much we want to curry at top level
|
-- This is how much we want to curry at top level
|
||||||
-- leading lambda Arity is used for function defs and metas
|
-- leading lambda Arity is used for function defs and metas
|
||||||
-- TODO - figure out how this will work with erasure
|
-- TODO - figure out how this will work with erasure
|
||||||
@@ -125,6 +133,8 @@ compileTerm tm@(App _ _ _) = case funArgs tm of
|
|||||||
defs <- getRef Defs
|
defs <- getRef Defs
|
||||||
args' <- traverse compileTerm args
|
args' <- traverse compileTerm args
|
||||||
arity <- arityForName fc nm
|
arity <- arityForName fc nm
|
||||||
|
let (Nothing) = compilePrimOp (show nm) args'
|
||||||
|
| Just cexp => pure cexp
|
||||||
case the (Maybe Def) $ lookupMap' nm defs of
|
case the (Maybe Def) $ lookupMap' nm defs of
|
||||||
Just (DCon SuccCon _ _) => applySucc args'
|
Just (DCon SuccCon _ _) => applySucc args'
|
||||||
_ => apply nm args' Lin arity
|
_ => apply nm args' Lin arity
|
||||||
|
|||||||
@@ -259,9 +259,9 @@ infixr 7 _++_
|
|||||||
class Concat a where
|
class Concat a where
|
||||||
_++_ : a → a → a
|
_++_ : a → a → a
|
||||||
|
|
||||||
pfunc sconcat : String → String → String := `(x,y) => x + y`
|
pfunc addString : String → String → String := `(x,y) => x + y`
|
||||||
instance Concat String where
|
instance Concat String where
|
||||||
_++_ = sconcat
|
_++_ = addString
|
||||||
|
|
||||||
|
|
||||||
pfunc jsEq uses (True False) : ∀ a. a → a → Bool := `(_, a, b) => a == b ? Prelude_True : Prelude_False`
|
pfunc jsEq uses (True False) : ∀ a. a → a → Bool := `(_, a, b) => a == b ? Prelude_True : Prelude_False`
|
||||||
@@ -872,14 +872,10 @@ instance ∀ a. {{Show a}} → Show (Maybe a) where
|
|||||||
show Nothing = "Nothing"
|
show Nothing = "Nothing"
|
||||||
show (Just a) = "Just {show a}"
|
show (Just a) = "Just {show a}"
|
||||||
|
|
||||||
|
|
||||||
-- TODO
|
|
||||||
|
|
||||||
pfunc isPrefixOf uses (True False): String → String → Bool := `(pfx, s) => s.startsWith(pfx) ? Prelude_True : Prelude_False`
|
pfunc isPrefixOf uses (True False): String → String → Bool := `(pfx, s) => s.startsWith(pfx) ? Prelude_True : Prelude_False`
|
||||||
pfunc isSuffixOf uses (True False): String → String → Bool := `(pfx, s) => s.endsWith(pfx) ? Prelude_True : Prelude_False`
|
pfunc isSuffixOf uses (True False): String → String → Bool := `(pfx, s) => s.endsWith(pfx) ? Prelude_True : Prelude_False`
|
||||||
pfunc strIndex : String → Int → Char := `(s, ix) => s[ix]`
|
pfunc strIndex : String → Int → Char := `(s, ix) => s[ix]`
|
||||||
|
|
||||||
|
|
||||||
instance ∀ a. {{Show a}} → Show (SnocList a) where
|
instance ∀ a. {{Show a}} → Show (SnocList a) where
|
||||||
show xs = show (xs <>> Nil)
|
show xs = show (xs <>> Nil)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user