-- String je synonymum pro [Char], a neda se pro nej primo odvodit instance
data S = S {fromS::String}

instance Show S where
  show (S s) = s

-- funkce s promennym poctem parametru

class Zobraz x where
  zobrazAcc::String->x

instance Zobraz S where
  zobrazAcc r = S r

instance (Show x, Zobraz y) => Zobraz (x->y) where
  zobrazAcc r x = zobrazAcc (r ++ show x)

zobraz::Zobraz x => x
zobraz = zobrazAcc ""

-- efektivnejsi (bez pripojovani na konec)

class ZobrazE x where
  zobrazEA::ShowS -> x

instance ZobrazE S where
  zobrazEA r = S (r "")

instance (Show x, ZobrazE y) => ZobrazE (x->y) where
  zobrazEA r x = zobrazEA (r . shows x)

zobrazE::ZobrazE x => x
zobrazE = zobrazEA id
