Re: No safety in numbers

2003-08-21 Thread Jon Cast
Konrad Hinsen [EMAIL PROTECTED] wrote: I am trying to write a larger piece of code using only type constraints for all the numbers, not specific types, in order to be able to choose the precision as late as possible. Good for you! (I say this in all seriousness.) This works rather well

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
On Thursday 21 August 2003 22:42, Jon Cast wrote: (or any other type I declare it to be). Right. But: you can declare it to have type Fractional alpha = alpha, which is the same type the constant has in the middle of an expression. I can make such a declaration, but it still gets converted

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
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 Then I run hugs Foo.hs and get: Foo :type x x :: Double

Re: No safety in numbers

2003-08-21 Thread David Roundy
On Thu, Aug 21, 2003 at 10:30:33PM +0200, Konrad Hinsen wrote: I might also declare all my constants to be Rational and use fromRational, but I don't know much about the Rational type. Do I have to worry about insufficient or compiler-dependent precision? I would guess that this is the best

Re: No safety in numbers

2003-08-21 Thread Tom Pledger
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 ::

Re: No safety in numbers

2003-08-21 Thread Konrad Hinsen
On Thursday 21 August 2003 23:39, Tom Pledger wrote: Try x :: Fractional a = a x = 0.5 instead. That way, the type signature is in the right place to prevent defaulting. Right - thanks! Konrad. ___ Haskell-Cafe mailing list [EMAIL