module Main where import System (getArgs) class Shape s where draw :: s-> String draw _ = "Shape" class Shape s=> Triangle s class Shape s=> Circle s data TriangleT = Triangle instance Shape TriangleT where draw Triangle = "Triangle" instance Triangle TriangleT data CircleT = Circle instance Shape CircleT where draw Circle = "Circle" instance Circle CircleT data ShapeT = forall s. Shape s=> Shape s instance Shape ShapeT where draw (Shape s) = draw s main :: IO () main = do a<- getArgs let s= case (head a) of "t" -> Shape Triangle; "c"-> Shape Circle putStrLn (draw s) data ShapeDef = ShapeDef instance Shape ShapeDef where draw _ = "Shape" main' :: IO () main' = do a<- getArgs let s= case (head a) of "t" -> Shape Triangle; "c"-> Shape Circle; _ -> Shape ShapeDef putStrLn (draw s)