4 ms·
What about Haskell then? {-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-} import Prelude (String, (++), show, Int, (==)
by dependenttypes 6y ago
What about Haskell then?
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
import Prelude (String, (++), show, Int, (==))
import qualified Prelude
class Add x y where
(+) :: x -> y -> y
instance Add Int String where
(+) x y = show x ++ y
instance Add Int Int where
(+) x y = x Prelude.+ y
instance Add String String where
(+) x y = x ++ y
a = ((1 :: Int) + (1 :: Int)) == 2
b = ((1 :: Int) + "aa") == "1aa"
c = ("a" + "aa") == "aaa"