You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
752 B
Plaintext

10 months ago
app "higher-order"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.1/Icc3xJoIixF3hCcfXrDwLCu4wQHtNdPyoJkEbkgIElA.tar.br" }
imports [pf.Stdout, pf.Task]
provides [main] to pf
main : Task.Task {} I32
main =
fn1 = bind Num.sub 3
fn2 = bindL Num.sub 3
fn3 = compose fn2 fn1
results =
[fn1 2, fn2 2, fn3 2]
|> List.map Num.toStr
|> List.mapWithIndex \e, idx -> "fn$(Num.toStr idx) -> $(e)"
|> Str.joinWith "\n"
Stdout.line "$(results)"
10 months ago
bind : (a, b -> c), a -> (b -> c)
bind = \fn, a ->
\b -> fn a b
bindL : (a, b -> c), b -> (a -> c)
bindL = \fn, b ->
\a -> fn a b
compose : (a -> b), (b -> c) -> (a -> c)
compose = \fn1, fn2 ->
\a -> fn1 a |> fn2