Skip to content

Instantly share code, notes, and snippets.

@monadplus
Created March 11, 2020 12:58
Show Gist options
  • Save monadplus/28f079800d8c7a57e93cbfd9256df64f to your computer and use it in GitHub Desktop.
Save monadplus/28f079800d8c7a57e93cbfd9256df64f to your computer and use it in GitHub Desktop.
Unboxed Types in GHC (Example)
{-# LANGUAGE MagicHash #-}
module Main where
-- More on https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#unboxed-types-and-primitive-operations
import GHC.Exts
showUnboxedInt :: Int# -> String
showUnboxedInt n = (show $ I# n) ++ "#"
main :: IO ()
main = putStrLn (showUnboxedInt 42#)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment