[Haskell-beginners] Explanation of double astrix

Paul Johnston Paul.A.Johnston at manchester.ac.uk
Wed Sep 3 12:00:02 EDT 2008


Hi
Was playing around with ghci and lambda expressions and:

*Main> map (\x -> 2 * x) [1 ..3]
[2,4,6]

Then thinking back to Fortran (yes I'm not young anymore!)

*Main> map (\x -> 2 ** x) [1 ..3]
[2.0,4.0,8.0]

Curious as to what is going on.
*Main> :t (\x -> 2 ** x)
(\x -> 2 ** x) :: (Floating t) => t -> t
*Main> :t (\x -> 2 * x)
(\x -> 2 * x) :: (Num t) => t -> t


Somehow the type has gone from Num to Floating
I am using the excellent (IMHO) tutorial by Hal Daume and the book by Graham 
Hutton but can find no clues.

Cheers Paul


More information about the Beginners mailing list