Created
November 6, 2017 17:34
-
-
Save bryal/545c4575a204790d964cb4fb67e19b48 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 TypeFamilies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
class Add a b where | |
type Ret a b :: * | |
add :: a -> b -> Ret a b | |
instance Add Int Double where | |
type Ret Int Double = Double | |
add a b = (fromIntegral a) + b | |
instance Add Int Int where | |
type Ret Int Int = Integer | |
add a b = (toInteger a) + (toInteger b) | |
main = ((>>) (putStrLn (show (add (1 :: Int) (2 :: Int)))) | |
(putStrLn (show (add (1 :: Int) (2 :: Double))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment