Skip to content

Instantly share code, notes, and snippets.

@acowley
Created July 16, 2018 15:58
Show Gist options
  • Save acowley/2f3ec7beb46b5039d51afb9d34407f54 to your computer and use it in GitHub Desktop.
Save acowley/2f3ec7beb46b5039d51afb9d34407f54 to your computer and use it in GitHub Desktop.
{-# LANGUAGE MagicHash, UnboxedTuples #-}
import GHC.Prim
import GHC.Types
main :: IO ()
main = do
xb@(I# x) <- fmap read getLine
case addWordC# 5## (int2Word# x) of
(# res, carryFlag #) ->
putStrLn ("5 + " ++ show xb ++ " = " ++ show (W# res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment