{-# LANGUAGE FlexibleInstances #-} unOp :: Read a => Show b => (a -> b) -> String -> String unOp f x = show . f $ read x binOp :: Read a => Read b => Show c => (a -> b -> c) -> String -> String -> String binOp f x y = show $ read x `f` read y instance Num String where (+) = binOp (+) (*) = binOp (*) abs = unOp abs signum = unOp signum fromInteger = show negate = unOp negate main = print $ 2 + 2 == "4"