No safety in numbers

Tom Pledger Tom.Pledger@peace.com
Fri, 22 Aug 2003 09:39:18 +1200


Konrad Hinsen writes:
 | On Thursday 21 August 2003 23:23, Jon Cast wrote:
 | > > I can make such a declaration, but it still gets converted to Double.
 | >
 | > How are you doing this?  I'm not seeing the behavior you describe.
 | 
 | module Foo where
 | x = 0.5 :: Fractional a => a

Try

    x :: Fractional a => a
    x = 0.5

instead.  That way, the type signature is in the right place to
prevent defaulting.

The other way is equivalent to

    x = (0.5 :: Fractional a => a)

which only confirms a type which is inferred anyway

    Prelude> :type 0.5
    0.5 :: Fractional a => a

but does not count as a type signature for x.

- Tom