
2011/5/8 Philippe Sismondi
On 2011-05-06, at 12:12 PM, Brent Yorgey wrote:
On Fri, May 06, 2011 at 11:34:47AM -0400, Philippe Sismondi wrote:
I am trying to understand the Typeclassopedia article by Brent Yorgey in Monad.Reader. I am simultaneously working my way through Real World Haskell, so I may be doing things a bit out of order.
I (more or less) understand that types and typeclasses are not the same. But it seems to me that they do conflate in a way, if we think of types as defined by functions on them. So why should we not be able to write:
f :: Num d -> String -> Int
You can have multiple class constraints, so it's not clear how you would write them using your syntax; how would you write : f :: (Eq d, Ord d) => d -> String -> Int ? Also, you only have to tell the class constraint once, with your syntax g :: (Num d) => d -> d -> d would become: g :: Num d -> Num d -> Num d but that syntax lets you write nonsense : h :: Num d -> Eq d -> Ord d David.