Skip to content

Commit

Permalink
add second test case using custom interpolation impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvgt committed Jan 15, 2025
1 parent fe5eddf commit 5ac9604
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GET https://api.effekt-lang.org/users/effekt/resource/42
Fix point combinator: \ f -> (\ x -> f x x) \ x -> f x x
41 changes: 41 additions & 0 deletions examples/pos/string_interpolation.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import splice
import stringbuffer

type Expr {
Var(id: String)
Abs(param: String, body: Expr)
App(fn: Expr, arg: Expr)
}

def pretty { prog: () => Unit / {literal, splice[Expr]} }: String = {
with stringBuffer
try {
prog()
do flush()
} with literal { s =>
resume(do write(s))
} with splice[Expr] { expr =>
expr match {
case Var(id) =>
do write(id)
case App(Abs(param, body), arg) =>
do write(pretty"(${Abs(param, body)}) ${arg}")
case App(fn, arg) =>
do write(pretty"${fn} ${arg}")
case Abs(param, body) =>
do write(s"\\ ${param} -> " ++ pretty"${body}")
}
resume(())
}
}

def main() = {
val domain = "https://api.effekt-lang.org"
val user = "effekt"
val resourceId = 42
println("GET ${domain}/users/${user}/resource/${resourceId.show}")

val fixpoint = Abs("f", App(Abs("x", App(Var("f"), App(Var("x"), Var("x")))), Abs("x", App(Var("f"), App(Var("x"), Var("x"))))))
println(pretty"Fix point combinator: ${fixpoint}")
}

10 changes: 0 additions & 10 deletions examples/pos/string_templates.effekt

This file was deleted.

0 comments on commit 5ac9604

Please sign in to comment.