[Haskell-beginners] can somebody explain the type of this expression?

Ovidiu Deac ovidiudeac at gmail.com
Mon Oct 27 21:02:02 UTC 2014


Makes sense. Thanks!

On Mon, Oct 27, 2014 at 10:54 PM, Brandon Allbery <allbery.b at gmail.com>
wrote:

> On Mon, Oct 27, 2014 at 4:47 PM, Ovidiu Deac <ovidiudeac at gmail.com> wrote:
>
>> Since the definition of expr looks like this:
>> Prelude> let f x = x * 2
>>
>> ...and 2 is an Int, I would expect that the type inferred for (*)  is
>> (Int -> Int -> Int) and thus f should be (Int -> Int)
>>
>
>     Prelude> :t 2
>     2 :: Num a => a
>
> Numeric literals are polymorphic.
> http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1360006.4.1
> is the official specification of this.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20141027/af6d2fac/attachment.html>


More information about the Beginners mailing list