{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
import Prelude hiding (sum)
import Data.Ratio

type RT = Ratio Integer

class (Num a, Show a) => PrintAllType a t where
    printAll' :: a -> t

instance (Num d, Show d) => PrintAllType d d where
    printAll' = id

instance (PrintAllType c r) => PrintAllType c (c -> r) where
    printAll' acc = \x -> printAll' (acc + x)

printAll :: PrintAllType b t => b -> t
printAll = printAll' 

main :: IO ()
main = do let a = (printAll :: RT -> RT -> RT -> RT) 5.0 3.2 1.1
              b = (printAll :: Int -> Int -> Int -> Int) 4 3 5
          print (a, b)
