Skip to content

Instantly share code, notes, and snippets.

@notogawa
Last active August 29, 2015 14:12
Show Gist options
  • Save notogawa/b7098cbdb31fae4828b6 to your computer and use it in GitHub Desktop.
Save notogawa/b7098cbdb31fae4828b6 to your computer and use it in GitHub Desktop.
{-# 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