[Haskell-cafe] Type problems

Daniel Fischer daniel.is.fischer at web.de
Sun Jul 25 08:38:43 EDT 2010


On Sunday 25 July 2010 14:12:03, Andrew Coppin wrote:
> Ivan Miljenovic wrote:
> > On 25 July 2010 05:50, Tobias Brandt <tob.brandt at googlemail.com> wrote:
> >> You have to fix the type of 1 and 6, e.g. by writing
> >> x <- randomRIO (1, 6) :: IO Int
> >> or
> >> x <- randomRIO (1, 6 :: Int)
> >>  GHCi defaults integral numbers to Int, that's why it works there.
> >
> > The default numeric type is Integer, not Int.
>
> Isn't there a "default" declaration where you can specify type
> defaulting?

Yes, you can have one default declaration per module.

The default default is (Integer, Double), meaning Integer is chosen if it's 
possible, otherwise Double is tried (for Fractional, Floating, ... 
constraints), if that doesn't satisfy all constraints either, error out 
with Ambiguous type variable ...



More information about the Haskell-Cafe mailing list