-
Notifications
You must be signed in to change notification settings - Fork 40
Checking Empty
child of Internal
nodes
#59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe that |
You are right! I'am not aware about specific features of GHC inlining, but AFAIU toList :: CritBit k v -> [(k, v)]
toList (CritBit root) = top root
where
top Empty = []
top node = go node []
go (Internal l r _ _) next = go l (go r next)
go (Leaf k v) next = (k,v) : next
go Empty next = error "CritBit: Empty child of Internal node" |
Pardon, for better performance the top Empty = []
top (Internal l r _ _) next = go l (go r next)
top (Leaf k v) next = (k,v) : next |
Documentation states that
Empty
allowed only as a root of the tree. Both performance and functions (e. g. binarySetOpWithKey) depends on this invariant. But, now it is not checked by tests at all.Unfortunately, there is no way to write such check function using public API only.
AFAIU there are two ways to solve this problem:
I think first variant is better.
The text was updated successfully, but these errors were encountered: