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
BinaryTree
type already supports empty trees, so expectingNothing
is redundant - empty list is a valid inorder and preorder traversal for an empty tree, so expecting
Nothing
is misleading, as it indicates that an error has occured. - A recursive implementation of
treeFromTraversals
naturally outputsJust Leaf
on empty inputs, thus, satisfying the tests requires an awkward wrapper function.