Finding simple autos after elab

This commit is contained in:
2024-10-26 20:41:28 -07:00
parent 9535675191
commit 44dd074a79
3 changed files with 81 additions and 9 deletions

27
tests/black/Auto.newt Normal file
View File

@@ -0,0 +1,27 @@
module Auto
ptype String
ptype Int
pfunc i2s : Int -> String := "(i) => ''+i"
pfunc _++_ : String -> String -> String := "(a,b) => a + b"
infixl 4 _++_
-- We need sugar and marking as class/instance on all of this
data Show : U -> U where
MkShow : { A : U } -> ((show : A) -> String) -> Show A
-- FIXME - we'd like to inline this, so `show _ {{showInt}} a` ends up as `i2s a`
show : {A : U} {{myshow : Show A}} -> A -> String
show {_} {{MkShow foo}} a = foo a
showInt : Show Int
showInt = MkShow i2s
ptype World
pfunc log : {A : U} -> A -> World := "(_, a) => console.log(a)"
main : Int -> World
main _ = log ("answer: " ++ show 42)