λ> "ARI"
"ARI"
λ> replicate 6 "ARI"
["ARI","ARI","ARI","ARI","ARI","ARI"]
λ> replicate 92 "ARI"
["ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI","ARI","ARI","ARI","ARI",
"ARI","ARI","ARI","ARI"]
λ> replicate 92 "MAMA"
["MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA","MAMA",
"MAMA","MAMA","MAMA","MAMA"]
increment : Nat -> Nat
increment n = n + 1
> x = 1 + 40
> y = increment x
👀 Now evaluating any watch expressions (lines starting with `>`) ...
4 | > x = 1 + 40
⧩
41
5 | > increment x
⧩
42
doDistributedStuff lotsOfData =
alice : Node
alice = spawn
job1 = at alice '(hugeComputation1 lotsOfData)
job2 = at spawn '(hugeComputation2 lotsOfData)
force job1 + force job2
spawn : {Remote} Node
at : Node -> '{Remote} a ->{Remote} (Future a)
force : Future a ->{Remote} a
doDistributedStuff : Stuff -> Nat
doDistributedStuff : Stuff ->{Remote} Nat
runLocal : '{Remote} a -> a
runLocalChaosMonkey : '{Remote} a -> a
Cloud.run : Params -> '{Remote} a -> a
> runLocal '(doDistributedStuff lotsOfData)
> runLocalChaosMonkey '(doDistributedStuff lotsOfData)
> Cloud.run usEast '(doDistributedStuff lotsOfData)
merge : (a -> a -> Boolean) -> [a] -> [a] -> [a]
merge lte a b =
go out a b = case (uncons a, uncons b) of
(None,_) -> out ++ b
(_,None) -> out ++ a
(Some (hA, tA), Some (hB, tB)) ->
if lte hA hB then go (snoc hA out) tA b
else go (snoc hB out) a tB
go [] a b
> merge (<) [1,3,4,99,504,799] [0,19,22,23]
93 | > merge (<) [1,3,4,99,504,799] [0,19,22,23]
⧩
[0, 1, 3, 4, 19, 22, 23, 99, 504, 799]
sort : (a -> a -> Boolean) -> [a] -> [a]
sort lte s =
if size s < 2 then s
else case halve s of (left, right) ->
r1 = sort lte left
r2 = sort lte right
merge lte r1 r2
> sort (<) [1,2,3,234,6,2,4,66,2,33,4,2,57]
112 | > sort (<) [1,2,3,234,6,2,4,66,2,33,4,2,57]
⧩
[1, 2, 2, 2, 2, 3, 4, 4, 6, 33, 57, 66, 234]
dsort : (a -> a -> Boolean) -> [a] ->{Remote} [a]
dsort lte s =
if size s < 2 then s
else case halve s of (left, right) ->
r1 = at spawn '(dsort lte left)
r2 = at spawn '(dsort lte right)
merge lte (force r1) (force r2)
> runLocal '(dsort (<) [1,2,3,234,6,2,4,66,2,33,4,2,57])
114 | > Remote.runLocal '(dsort (<) [1,2,3,234,6,2,4,66,2,33,4,2,57])
⧩
[1, 2, 2, 2, 2, 3, 4, 4, 6, 33, 57, 66, 234]
dsort : (a -> a -> Boolean) -> [a] ->{Remote} [a]
dsort lte s =
if size s < 2 then s
else case halve s of (left, right) ->
r1 = at spawn '(dsort lte left)
r2 = at spawn '(dsort lte right)
merge lte (force r1) (force r2)
sort : (a -> a -> Boolean) -> [a] -> [a]
sort lte s =
if size s < 2 then s
else case halve s of (left, right) ->
r1 = sort lte left
r2 = sort lte right
merge lte r1 r2
doDistributedStuff lotsOfData =
alice : Node
alice = spawn
job1 = at alice '(hugeComputation1 lotsOfData)
job2 = at spawn '(hugeComputation2 lotsOfData)
force job1 + force job2
dsort : (a -> a -> Boolean) -> [a] ->{Remote} [a]
dsort lte s =
if size s < 2 then s
else case halve s of (left, right) ->
r1 = at spawn '(dsort lte left)
r2 = at spawn '(dsort lte right)
merge lte (force r1) (force r2)
dreduce : Monoid a -> [a] ->{Remote} a
dreduce m s =
if size s < 2 then Monoid.orElse m (Sequence.head s)
else case halve s of (left, right) ->
r1 = at spawn '(dreduce m left)
r2 = at spawn '(dreduce m right)
Monoid.op m (force r1) (force r2)
dsort : (a -> a -> Boolean) -> [a] ->{Remote} [a]
dsort lte s =
dreduce (Monoid (merge lte) [])
(Sequence.map single s)
dreduce : Monoid a -> [a] ->{Remote} a
dsort : (a -> a -> Boolean) -> [a] ->{Remote} [a]
dsort lte s =
dreduce (Monoid (merge lte) [])
(Sequence.map single s)
bob = spawn
at bob '(factorial n)
.
.
factorial n =
foldLeft (*) 1 (range 1 (n + 1))
blah z =
foldLeft (*) 1 (range 1 (z + 1))
#Q82jfkasdf823jbc192
at bob '(factorial n)
at bob '(#Q82jfkasdf823jbc192 n)
.
.
.
.
.
.
.
.
factorial n =
foldLeft (*) 1 (range 1 (n + 1))
#Q82jfkasdf823jbc192
at bob '(factorial n)
at bob '(#Q82jfkasdf823jbc192 n)
.
.
factorial n = 42
#Zhsdf238jsfjasdWjd3