mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Merge branch 'trunk' into dict-more
This commit is contained in:
commit
fe98229aa3
19 changed files with 691 additions and 193 deletions
15
examples/benchmarks/Closure1.roc
Normal file
15
examples/benchmarks/Closure1.roc
Normal file
|
@ -0,0 +1,15 @@
|
|||
app "closure1"
|
||||
packages { base: "platform" }
|
||||
imports [base.Task]
|
||||
provides [ main ] to base
|
||||
|
||||
# see https://github.com/rtfeldman/roc/issues/985
|
||||
|
||||
main : Task.Task {} []
|
||||
main =
|
||||
Task.succeed (foo toUnitBorrowed "a long string such that it's malloced")
|
||||
|> Task.map (\_ -> {})
|
||||
|
||||
toUnitBorrowed = \x -> Str.countGraphemes x
|
||||
|
||||
foo = \f, x -> f x
|
15
examples/benchmarks/Closure2.roc
Normal file
15
examples/benchmarks/Closure2.roc
Normal file
|
@ -0,0 +1,15 @@
|
|||
app "closure2"
|
||||
packages { base: "platform" }
|
||||
imports [base.Task]
|
||||
provides [ main ] to base
|
||||
|
||||
# see https://github.com/rtfeldman/roc/issues/985
|
||||
|
||||
main : Task.Task {} []
|
||||
main =
|
||||
x : Str
|
||||
x = "a long string such that it's malloced"
|
||||
|
||||
Task.succeed {}
|
||||
|> Task.map (\_ -> x)
|
||||
|> Task.map (\_ -> {})
|
15
examples/benchmarks/Closure3.roc
Normal file
15
examples/benchmarks/Closure3.roc
Normal file
|
@ -0,0 +1,15 @@
|
|||
app "closure3"
|
||||
packages { base: "platform" }
|
||||
imports [base.Task]
|
||||
provides [ main ] to base
|
||||
|
||||
# see https://github.com/rtfeldman/roc/issues/985
|
||||
|
||||
main : Task.Task {} []
|
||||
main =
|
||||
x : Str
|
||||
x = "a long string such that it's malloced"
|
||||
|
||||
Task.succeed {}
|
||||
|> Task.after (\_ -> Task.succeed x |> Task.map (\_ -> {}))
|
||||
|
16
examples/benchmarks/Closure4.roc
Normal file
16
examples/benchmarks/Closure4.roc
Normal file
|
@ -0,0 +1,16 @@
|
|||
app "closure4"
|
||||
packages { base: "platform" }
|
||||
imports [base.Task]
|
||||
provides [ main ] to base
|
||||
|
||||
# see https://github.com/rtfeldman/roc/issues/985
|
||||
|
||||
main : Task.Task {} []
|
||||
main =
|
||||
x : Str
|
||||
x = "a long string such that it's malloced"
|
||||
|
||||
Task.succeed {}
|
||||
|> Task.after (\_ -> Task.succeed x)
|
||||
|> Task.map (\_ -> {})
|
||||
|
|
@ -24,10 +24,10 @@ after = \effect, transform ->
|
|||
|
||||
map : Task a err, (a -> b) -> Task b err
|
||||
map = \effect, transform ->
|
||||
Effect.after effect \result ->
|
||||
Effect.map effect \result ->
|
||||
when result is
|
||||
Ok a -> Task.succeed (transform a)
|
||||
Err err -> Effect.always (Err err) # Task.fail err does not work. WEIRD!
|
||||
Ok a -> Ok (transform a)
|
||||
Err err -> Err err
|
||||
|
||||
putLine : Str -> Task {} *
|
||||
putLine = \line -> Effect.map (Effect.putLine line) (\_ -> Ok {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue