[Haskell-cafe] Newbie question: inferred type

David Laffin dl_y_post at yahoo.co.uk
Thu Mar 30 02:51:55 EST 2006


Hi,

Newbie question. Given the inferred type for square,
the
inferred types for quad1, quad2 and quad3 are what I
would
expect. Is there a straightforward explanation (i.e.
one
that a newbie would understand) as to why the inferred
type
for quad4 is less general?

Regards,
dl

-- GHC Interactive, version 6.4, for Haskell 98.

Prelude> let square x = x * x
Prelude> :t square
square :: (Num a) => a -> a

Prelude> let quad1 x = square (square x)
Prelude> :t quad1
quad1 :: (Num a) => a -> a

Prelude> let quad2 x = square $ square x
Prelude> :t quad2
quad2 :: (Num a) => a -> a

Prelude> let quad3 x = (square . square) x
Prelude> :t quad3
quad3 :: (Num a) => a -> a

Prelude> let quad4 = square . square
Prelude> :t quad4
quad4 :: Integer -> Integer





		
___________________________________________________________ 
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com


More information about the Haskell-Cafe mailing list