I feel like the first test of “satellite”
Case { description = "Empty tree"
, preorder = ""
, inorder = ""
, expected = Nothing
}
should be
Case { description = "Empty tree"
, preorder = ""
, inorder = ""
, expected = Just Leaf
}
Reasons:
- the
BinaryTreetype already supports empty trees, so expectingNothingis redundant - empty list is a valid inorder and preorder traversal for an empty tree, so expecting
Nothingis misleading, as it indicates that an error has occured. - A recursive implementation of
treeFromTraversalsnaturally outputsJust Leafon empty inputs, thus, satisfying the tests requires an awkward wrapper function.