If you've got (.) :: String -> String -> String (+) :: (Num a) => a -> a -> a
then you could indeed have your language automatically massage the arguments to those functions into the correct type wherever possible.
(Of course, in some cases, it might still not be possible to do in a sane way... Converting a GTK window into an IRC command isn't something I'd want to leave to the compiler - and I certainly don't want to be forced to do it myself when I declare the GTK window type, just because someone else declared the IRC type first - so I think there's still a place for type errors. Of course, if someone else wants to define how it should work - I'm happy to let them.)
Ok - so we'd like to massage the arguments to our functions into the correct type wherever possible. Perhaps a good way to do this would be with user defined conversion functions (so that the conversion can be as intelligent as possible at every stage - and do the right thing more often than not).
In this case, we want f :: Num -> String in order for (.) to do what we want. In other cases, we'll probably want f :: x -> String and we'll need a way for the compiler to know what function to call in order to do this massaging.
Let's rename the function f to something more intuative, like show, and say that all types x for which show x makes sense are of class Show. Now we can have: (.) :: (Show a) => a -> a -> a
no subject
If you've got
(.) :: String -> String -> String
(+) :: (Num a) => a -> a -> a
then you could indeed have your language automatically massage the arguments to those functions into the correct type wherever possible.
(Of course, in some cases, it might still not be possible to do in a sane way... Converting a GTK window into an IRC command isn't something I'd want to leave to the compiler - and I certainly don't want to be forced to do it myself when I declare the GTK window type, just because someone else declared the IRC type first - so I think there's still a place for type errors. Of course, if someone else wants to define how it should work - I'm happy to let them.)
Ok - so we'd like to massage the arguments to our functions into the correct type wherever possible. Perhaps a good way to do this would be with user defined conversion functions (so that the conversion can be as intelligent as possible at every stage - and do the right thing more often than not).
In this case, we want f :: Num -> String in order for (.) to do what we want. In other cases, we'll probably want f :: x -> String and we'll need a way for the compiler to know what function to call in order to do this massaging.
Let's rename the function f to something more intuative, like show, and say that all types x for which show x makes sense are of class Show. Now we can have:
(.) :: (Show a) => a -> a -> a
...will that do what you want? ;)