Re: No safety in numbers

2003-09-14 Thread Marcin 'Qrczak' Kowalczyk
Dnia czw 21. sierpnia 2003 22:30, Konrad Hinsen napisaƂ: > k_B = 0.0083144708636327096 > > The trouble is that k_B then becomes "Double" by default (or any other > type I declare it to be). Declare it as k_B :: Fractional a => a Performance may suffer even in GHC if optimization is turned off.

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 [EM

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 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

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 :: Dou

Re: No safety in numbers

2003-08-21 Thread Jon Cast
Konrad Hinsen <[EMAIL PROTECTED]> wrote: > 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 > > expressio

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 conv

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 wel

No safety in numbers

2003-08-21 Thread Konrad Hinsen
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. This works rather well (something I can't say of many other languages), but one problem I keep running into is constan