aboutsummaryrefslogtreecommitdiff
path: root/examples/37-generic-functions/src/HelloWorld.shed
blob: d40e9103dc8e108f7cb3d12885791cab9e7b6b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pub fun main() ! Io -> Unit {
    val message = compose(
        fn (a: String) { a + ", " },
        fn (b: String) { b + "world!\n" },
    )("hello");
    print!(message);
}

fun compose[A, B, C](
    f: fn (A) -> B,
    g: fn (B) -> C
) -> fn (A) -> C {
    fn (a) { g(f(a)) }
}