Add crash implementation to document compiler bug

main
trivernis 3 months ago
parent 4c9edbfadb
commit 85c9d31950
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 7E6D18B61C8D2F4B

@ -0,0 +1,23 @@
app "crash-me"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.7.1/Icc3xJoIixF3hCcfXrDwLCu4wQHtNdPyoJkEbkgIElA.tar.br" }
imports [pf.Stdout]
provides [main] to pf
main =
fn1 = bind Num.sub 2
fn2 = compose fn1 fn1
results =
[fn1, fn2]
|> List.map \f -> f 2
|> List.map Num.toStr
|> Str.joinWith "\n"
Stdout.line "$(results)"
bind : (a, b -> c), a -> (b -> c)
bind = \fn, a ->
\b -> fn a b
compose : (a -> b), (b -> c) -> (a -> c)
compose = \fn1, fn2 ->
\a -> fn1 a |> fn2

@ -5,13 +5,24 @@ app "higher-order"
main : Task.Task {} I32
main =
mySum = bind anySum 2
Stdout.line "$(Num.toStr (mySum 2))"
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)"
bind : (a, b -> c), a -> (b -> c)
bind = \fn, a ->
\b -> fn a b
anySum : Num a, Num a -> Num a
anySum = \a, b ->
a + b + 2
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

Loading…
Cancel
Save