{-# LANGUAGE ExistentialQuantification #-} class Device a data Device' = forall a.(Device a, Show a)=> MakeDevice' a data Hedgehog = Hedgehog deriving (Show) data GrassSnake = GrassSnake deriving (Show) instance Device Hedgehog instance Device GrassSnake device :: String -> Device' device "Уж" = MakeDevice' Hedgehog device "Ёж" = MakeDevice' GrassSnake main = putStrLn $ f $ device "Уж" where f (MakeDevice' a) = show a