[Haskell-cafe] type-class inference
Patrick Browne
patrick.browne at dit.ie
Sat Aug 13 00:52:23 CEST 2011
Hi,
Why does the Haskell :type command only sometimes print the type-class?
Should I expect type-class inference as well as type inference?
Maybe the type-class is inferred where possible, but not always printed?
Thanks,
Pat
-- Code
k x = x + 3
data T = T
class A a where
g::a -> a
g a = a
instance A T where
instance A Integer where
-- The results from the above code.
-- First in the case of a function. Inferred the Num class
*Main> :t k
k :: forall a. (Num a) => a -> a
*Main> :t k 3
k 3 :: forall t. (Num t) => t
-- Did not print type class
*Main> :t k (3::Integer)
k (3::Integer) :: Integer
-- Second in the case of a method of a type class.
-- Inferred Num
*Main> :t g 3
g 3 :: forall t. (A t, Num t) => t
-- Did not print class A.
*Main> :t g T
g T :: T
-- Did not print any class.
*Main> :t g (3::Integer)
g (3::Integer) :: Integer
This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie
More information about the Haskell-Cafe
mailing list