Type classes vs C++ overloading Re: [Haskell-cafe] Messing around with types [newbie]

Dan Weston westondan at imageworks.com
Thu Jun 21 11:39:35 EDT 2007

Bulat Ziganshin wrote:
> Hello Cristiano,
> Thursday, June 21, 2007, 4:46:27 PM, you wrote:
>> class FooOp a b where
>>   foo :: a -> b -> IO ()
>> instance FooOp Int Double where
>>   foo x y = putStrLn $ (show x) ++ " Double " ++ (show y)
> this is rather typical question :)  unlike C++ which resolves any
> overloading at COMPILE TIME, selecting among CURRENTLY available
> overloaded definitions and complaining only when when this overloading
> is ambiguous, type classes are the RUN-TIME overloading mechanism

As I understood it, it was at COMPILE TIME (i.e. no type witness) 
whenever explicitly type-annotated, implicitly when not exported from a 
module, or when inlined at the call site, at least in GHC. Or did I get 
this wrong?


More information about the Haskell-Cafe mailing list