Is there a more concise way to write the following haskell code:
{-# LANGUAGE FlexibleInstances #-}
class Greetable g where
hi :: g -> String
-- Here i should list all instances of Num
instance Greetable Float where
hi s = "Hi number! " ++ show s
instance Greetable Int where
hi s = "Hi number! " ++ show s
instance Greetable Double where
hi s = "Hi number! " ++ show s
-- Etc.
-- Here is other stuff
instance Greetable String where
hi s = "Hi string! " ++ s
EDIT: I would like the hi
function to be able to account for any future instances of the class Num
.