Open folkertdev opened 3 years ago
FWIW, I get this output today:
[jan@framey roc]$ cat test.roc
app "rosetree"
packages { pf: "examples/hello-world/platform/main.roc" }
imports []
provides [main] to pf
main =
myTree : Tree Str
myTree = tree "foo" [ singleton "bar", singleton "baz" ]
myTree
|> count
|> Str.fromInt
Tree a : [ Tree a (List (Tree a)) ]
tree : a, List (Tree a) -> Tree a
tree = \a, t -> Tree a t
singleton : a -> Tree a
singleton = \x -> Tree x []
count : Tree Str -> I64
count = \t -> foldl (\_, x -> x + 1) 0 t
foldl : (Str, I64 -> I64), I64, Tree Str -> I64
foldl = \f, acc, (Tree d xs) -> listFoldl xs (foldlHelper f) (f d acc)
listFoldl : List (Tree Str), (Tree Str, I64 -> I64), I64 -> I64
listFoldl = \a,b,c -> List.walk a b c
foldlHelper : (Str, I64 -> I64) -> (Tree Str, I64 -> I64)
foldlHelper = \f -> \subtree, subacc ->
foldl f subacc subtree
# foldl : (a, b -> b), b, Tree a -> b
# foldl = \f, acc, (Tree d xs) -> List.walk xs (foldlHelper f) (f d acc)
#
# foldlHelper : (a, b -> b) -> (Tree a, b -> b)
# foldlHelper = \f -> \subtree, subacc ->
# foldl f subacc subtree
[jan@framey roc]$ roc test.roc
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)
[jan@framey roc]$
This runs into all kinds of layout and recursion problems.