Quick actions

cmd+k|ctrl+k

Navigation

Languages

Detect arithmetic underflow with unsigned integers

Snippet info

Language

Haskell

Visibility

public

Author

rightfold

Created

2017-02-27T10:29:47Z

Updated

2017-02-27T10:30:59Z

module Main
  ( main
  ) where

sub :: Word -> Word -> Maybe Word
sub a b | a >= b    = Just (a - b)
        | otherwise = Nothing

main :: IO ()
main = do
  print $ sub 2 1
  print $ sub 1 2
INFO