From 59ec0a666ee265e7726cd76f8362d47cdbe28c1d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 29 Oct 2023 21:53:47 +0000 Subject: Add example of inferring param type --- examples/20-function-expression-infer-param-type/shed.toml | 7 +++++++ .../20-function-expression-infer-param-type/src/HelloWorld.shed | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 examples/20-function-expression-infer-param-type/shed.toml create mode 100644 examples/20-function-expression-infer-param-type/src/HelloWorld.shed (limited to 'examples') diff --git a/examples/20-function-expression-infer-param-type/shed.toml b/examples/20-function-expression-infer-param-type/shed.toml new file mode 100644 index 00000000..1503d826 --- /dev/null +++ b/examples/20-function-expression-infer-param-type/shed.toml @@ -0,0 +1,7 @@ +[[shed.bins]] +name = "hello-world" +main-namespace = "HelloWorld" + +[[shed.examples]] +bin = "hello-world" +expected-output = "hello, world\nworld, hello" diff --git a/examples/20-function-expression-infer-param-type/src/HelloWorld.shed b/examples/20-function-expression-infer-param-type/src/HelloWorld.shed new file mode 100644 index 00000000..e91bc5e0 --- /dev/null +++ b/examples/20-function-expression-infer-param-type/src/HelloWorld.shed @@ -0,0 +1,8 @@ +pub fun main() ! Io -> Unit { + printHelloWorld!(fn (left, right) { left + ", " + right + "\n" }); + printHelloWorld!(fn (left, right) { right + ", " + left + "\n" }) +} + +fun printHelloWorld(combine: fn (String, String) -> String) !Io -> Unit { + print!(combine("hello", "world")); +} -- cgit v1.2.3