-
-
Save OsePedro/b0a1199b2fc5a70ce9281ab53e6c36f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | |
import System.Exit | |
newtype MyWord = MyWord Word deriving(Enum,Eq,Integral,Num,Ord,Real) | |
myInt :: MyWord -> Int | |
myInt = fromIntegral | |
{-# INLINE myInt #-} | |
fromMyWord :: Num a => MyWord -> a | |
fromMyWord (MyWord w) = fromIntegral w | |
{-# INLINE fromMyWord #-} | |
myInt2 :: MyWord -> Int | |
myInt2 = fromMyWord | |
int :: Word -> Int | |
int = fromIntegral | |
fib :: Integral a => a -> a | |
fib 0 = 0 | |
fib 1 = 1 | |
fib n = fib (n-1) + fib (n-2) | |
main = exitWith $ ExitFailure $ myInt (fib 10) + myInt2 (fib 10) + int (fib 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment