foundation
foundation copied to clipboard
Change Difference type in CountOf to return a Maybe
we should only have CountOf that are positive, and the only way to create negative count of would be using the (-) operation. By having (-) returning a Maybe CountOf, we prevent most negative count bug.
also having this we can replace the code that uses (-) on CountOf which is usually :
if n >= m
then ..ok,we have element to remove.. now the size is n - m..
else ..do_something_not_enough_data..
into something that is safer by construction:
case n - m of
Nothing -> ..do_something_not_enough_data
Just newSize -> ...remove_something_and_then_newSize...
I'm taking this ticket
Can this be closed?