Last active
August 29, 2015 14:12
-
-
Save notogawa/b7098cbdb31fae4828b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
import Prelude hiding ( (+) ) | |
import qualified Prelude as P | |
class FuzzyAddable a b c where | |
(+) :: a -> b -> c | |
instance FuzzyAddable String Int String where | |
a + b = a ++ show b | |
instance Num a => FuzzyAddable a a a where | |
a + b = a P.+ b | |
test1 :: String | |
test1 = "5" + (1 :: Int) | |
test2 :: Int | |
test2 = (5 :: Int) + (1 :: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment