Type Constraints : Can they be inferred from the datatype of a function's arguments?

Viewed 1089

This

newtype ( Show a , Show b , Show c ) => T a b c = T Int
t :: T a b c -> a -> b -> c -> String
t ( T x ) a b c = show a ++ show b ++ show c

gives me an error:

No instance for (Show c)
      arising from a use of `show'
    In the second argument of `(++)', namely `show c'
    In the second argument of `(++)', namely `show b ++ show c'
    In the expression: show a ++ show b ++ show c

But this

newtype ( Show a , Show b , Show c ) => T a b c = T Int
t :: ( Show a , Show b , Show c ) => T a b c -> a -> b -> c -> String
t ( T x ) a b c = show a ++ show b ++ show c

compiles.

Why?

In the first case, doesn't "T a b c" already imply that "( Show a , Show b , Show c )"? Why is it necessary to explicitly specify the constraint?

2 Answers
Related