[Haskell-cafe] Re: Newbie question
Jon Fairbairn
jon.fairbairn at cl.cam.ac.uk
Mon Jan 21 11:56:08 EST 2008
"Alexander Seliverstov" <seliverstov.a at gmail.com> writes:
> How does caller choose which particular instance of Num they want?
They specify the type... or just pass the result to
something that specifies the type. Try it in ghci:
Prelude> let f:: Integral i => Integer -> i; f = fromIntegral
Prelude> let g :: Int -> Int; g = id
Prelude> :t g (f 5)
g (f 5) :: Int
Prelude> let h :: Integer -> Integer; h = id
Prelude> :t h (f 5)
h (f 5) :: Integer
Prelude>
> What the difference between haskell class and interface in object-oriented
> languge such Java or C#?
Really they are completely different animals that look a lot
alike because they serve similar purposes -- convergent
evolution!
--
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
More information about the Haskell-Cafe
mailing list