Daniel Fischer <daniel.is.fisc...@web.de> writes:

> On Wednesday 17 November 2010 19:09:16, Jerzy M wrote:
>> Hallo,
>> let me take this simple function: (2*).
>> If I check its type
>>
>> :t (2*)
>>
>> I'll obtain
>> (2*) :: (Num a) => a -> a
>>
>> But now it suffices to write
>> g = (2*)
>> and check
>>
>> :t g
>>
>> to obtain
>> g :: Integer -> Integer
>>
>> One more combination, now I write
>> h x = (2*) x
>> and check once more
>>
>> :t h
>>
>> to get
>> h :: (Num a) => a -> a
>>
>> So my question is: why (in this second example) Integer is inferred?
>> What makes a difference?
>
> The monomorphism restriction.

And default. If you load this into ghci

   module Main where

   default (Int)

   g = (2*)
   main = putStrLn "foo"

and type :t g

you'll get Int -> Int

-- 
Jón Fairbairn                                 jon.fairba...@cl.cam.ac.uk



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to