int add becomes +

This commit is contained in:
2025-09-20 19:58:39 -07:00
parent 49c90cce6d
commit cc7d8b4968
5 changed files with 16 additions and 7 deletions

View File

@@ -52,6 +52,14 @@ lamArity : Tm -> Nat
lamArity (Lam _ _ _ _ t) = S (lamArity t)
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
-- leading lambda Arity is used for function defs and metas
-- TODO - figure out how this will work with erasure
@@ -125,6 +133,8 @@ compileTerm tm@(App _ _ _) = case funArgs tm of
defs <- getRef Defs
args' <- traverse compileTerm args
arity <- arityForName fc nm
let (Nothing) = compilePrimOp (show nm) args'
| Just cexp => pure cexp
case the (Maybe Def) $ lookupMap' nm defs of
Just (DCon SuccCon _ _) => applySucc args'
_ => apply nm args' Lin arity

View File

@@ -259,9 +259,9 @@ infixr 7 _++_
class Concat a where
_++_ : 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
_++_ = sconcat
_++_ = addString
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 (Just a) = "Just {show a}"
-- TODO
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 strIndex : String Int Char := `(s, ix) => s[ix]`
instance a. {{Show a}} Show (SnocList a) where
show xs = show (xs <>> Nil)