-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add second test case using custom interpolation impl
- Loading branch information
Showing
3 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/pos/string_templates.check → examples/pos/string_interpolation.check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") | ||
} | ||
|
This file was deleted.
Oops, something went wrong.