This is unsafe in that any type can be substituted for A, yet at runtime,
if an array is found in some node value an exception will be thrown, because
we use Array.isArray to discriminate between leaves and branches.
The function is perfectly safe if the type A is not an array.
Flatten a tree level into an
ArrayTree<A>.This is unsafe in that any type can be substituted for
A, yet at runtime, if an array is found in some node value an exception will be thrown, because we useArray.isArrayto discriminate between leaves and branches.The function is perfectly safe if the type
Ais not an array.