foundation icon indicating copy to clipboard operation
foundation copied to clipboard

Change Difference type in CountOf to return a Maybe

Open vincenthz opened this issue 8 years ago • 2 comments

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...

vincenthz avatar Jun 09 '17 08:06 vincenthz

I'm taking this ticket

madidier avatar Jun 10 '17 13:06 madidier

Can this be closed?

ProofOfKeags avatar Jul 16 '18 02:07 ProofOfKeags