class Named t where name :: t -> String data Dog = Dog String instance Named Dog where name (Dog n) = n main = print $ name $ Dog "Sharik"