Files
loop/src/Dodge/Base/Arithmetic.hs
T
2022-06-19 11:34:59 +01:00

11 lines
270 B
Haskell

module Dodge.Base.Arithmetic where
import MaybeHelp
decreaseToZero :: Int -> Int
decreaseToZero = max 0 . subtract 1
decreaseToNothing' :: (Num a, Ord a) => Maybe' a -> Maybe' a
decreaseToNothing' ma = case ma of
Just' x | x > 0 -> Just' (x - 1)
_ -> Nothing'