
Greetings. Haskell has arbitrary precision integers, in the form of the Integer type. Is there a type somewhere that implements arbitrary precision fractional values?

On Sun, May 06, 2007 at 05:15:08PM +0100, Andrew Coppin wrote:
Greetings.
Haskell has arbitrary precision integers, in the form of the Integer type. Is there a type somewhere that implements arbitrary precision fractional values?
Yes, Rational in the Prelude (with extra functions in Ratio) Prelude> let fibs = (1::Rational) : 1 : zipWith (+) fibs (tail fibs) Prelude> let grs = zipWith (/) (tail fibs) fibs Prelude> take 10 grs [1%1,2%1,3%2,5%3,8%5,13%8,21%13,34%21,55%34,89%55] Prelude> take 10 (zipWith (-) grs (tail grs)) [(-1)%1,1%2,(-1)%6,1%15,(-1)%40,1%104,(-1)%273,1%714,(-1)%1870,1%4895] Prelude>

Greetings.
Haskell has arbitrary precision integers, in the form of the Integer type. Is there a type somewhere that implements arbitrary precision fractional values?
Yes, Rational in the Prelude (with extra functions in Ratio)
Prelude> let fibs = (1::Rational) : 1 : zipWith (+) fibs (tail fibs) Prelude> let grs = zipWith (/) (tail fibs) fibs Prelude> take 10 grs [1%1,2%1,3%2,5%3,8%5,13%8,21%13,34%21,55%34,89%55] Prelude> take 10 (zipWith (-) grs (tail grs)) [(-1)%1,1%2,(-1)%6,1%15,(-1)%40,1%104,(-1)%273,1%714,(-1)%1870,1%4895] Prelude>
Ah yes, you're right. Well, you learn something every day... OOC, is there a reason why you can't just write "5%10"?

On May 6, 2007, at 12:59 , Andrew Coppin wrote:
OOC, is there a reason why you can't just write "5%10"?
Prelude> :t 5%10 <interactive>:1:1: Not in scope: `%' Prelude> :m +Data.Ratio Prelude Data.Ratio> :t 5%10 5%10 :: (Integral t) => Ratio t Prelude Data.Ratio> I'm actually a bit surprised that's not in Prelude. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Brandon S. Allbery KF8NH wrote:
OOC, is there a reason why you can't just write "5%10"?
Prelude> :t 5%10
<interactive>:1:1: Not in scope: `%' Prelude> :m +Data.Ratio Prelude Data.Ratio> :t 5%10 5%10 :: (Integral t) => Ratio t Prelude Data.Ratio>
I'm actually a bit surprised that's not in Prelude.
Likewise... Oh, by the way, thanks for the extra syntax. It's really annoying having to locate Notepad.exe on the start menu, type "import Blah", save it as "Thing.hs", open Windoze Explorer, locate Thing.hs, and then double-click it just so that I can try stuff out in GHCi...

Andrew Coppin wrote:
...
Likewise...
Oh, by the way, thanks for the extra syntax. It's really annoying having to locate Notepad.exe on the start menu, type "import Blah", save it as "Thing.hs", open Windoze Explorer, locate Thing.hs, and then double-click it just so that I can try stuff out in GHCi...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
God that sounds painful. As well as reading about ghci [1] you might consider Emacs and haskell-mode for a productive environment. [1] http://www.haskell.org/ghc/docs/6.4.2/html/users_guide/ghci.html -- View this message in context: http://www.nabble.com/Arbitrary-precision--tf3700066.html#a10348633 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Oh, by the way, thanks for the extra syntax. It's really annoying having to locate Notepad.exe on the start menu, type "import Blah", save it as "Thing.hs", open Windoze Explorer, locate Thing.hs, and then double-click it just so that I can try stuff out in GHCi... God that sounds painful. As well as reading about ghci [1] you might consider Emacs and haskell-mode for a productive environment.
I started out using Hugs. (The 2003 edition.) I used it for ages, and it worked pretty well. However, later they released a new version. So I downloaded and installed that. On one hand, it has a cool updated GUI. On the other hand, it behaves very erratically. Truncates output, produces spurios extra output, sometimes randomly closes all by itself, and every now and then Dr Watson pays me a visit. Eventually I took the plunge and spent 6 weeks downloading GHC. (Basically because I wanted to be able to compile stuff to make it go faster.) GHCi is drastically less inviting then Hugs; hell, the window isn't even scrollable! (Also, is there a reason why the installer doesn't add GHC to your searchpath?) Starting GHCi and typing an 8-mile long file path with no tab completion isn't fun. However, after about 2 months, I discovered that double-clicking a Haskell file instantly loads it into GHCi - which is obviously much easier. It's still annoying having to write "import Data.List", save it, and double-click it just so I can (say) look up the type for sortBy. (At home I just use Hoogle, but at work that takes too long.) Eventually I got used to using GHC, and used Hugs less and less due to its flakiness, and the fact that half the libraries in the world only work with GHC. (The other half don't work with any system at all.) In fact, the other day I decided to install Hugs completely. Special surprise: the uninstaller is broken. You cannot uninstall Hugs. Oh, thanks for that... Anyway... long ramble over... Emacs isn't my operating system of choice. I prefer to use SciTE (which is *just* a text editor - as in, it doesn't also come with an integrated toaster and alarm clock). One SciTE window open, one command prompt pointing at the source folder... seems to work fairly well. Would be nice if SciTE would colourise Haskell syntax, but since Haskell is so absurdly hard to parse, I guess that's asking a lot. ;-) PS. What the heck email client puts URLs in as footnotes?

On Sun, May 06, 2007 at 10:02:55PM +0100, Andrew Coppin wrote:
Anyway... long ramble over... Emacs isn't my operating system of choice. I prefer to use SciTE (which is *just* a text editor - as in, it doesn't also come with an integrated toaster and alarm clock). One SciTE window open, one command prompt pointing at the source folder... seems to work
How about a ghci prompt? You can reload using <colon> <ret>
fairly well. Would be nice if SciTE would colourise Haskell syntax, but since Haskell is so absurdly hard to parse, I guess that's asking a lot. ;-)
Indeed, it has never been done. I'm not entirely convinced it's decidable. But that hasn't stopped anybody from writing parsers for the commonly used subset of haskell! Also, highlighting normally does not require a full parser, just a lexer (which is easy). (Beschers' experimental Emacs mode actually highlights type errors...) Stefan

Andrew Coppin wrote:
[...] Anyway... long ramble over... Emacs isn't my operating system of choice. I prefer to use SciTE (which is *just* a text editor - as in, it doesn't also come with an integrated toaster and alarm clock). One SciTE window open, one command prompt pointing at the source folder... seems to work fairly well. Would be nice if SciTE would colourise Haskell syntax, but since Haskell is so absurdly hard to parse, I guess that's asking a lot. ;-)
Obviously you should stick with it if you're happy with it but It still sounds pretty painful to me...using haskell-mode you have highlighted code in one frame, ghci in another, resting the point over a function call displays the type, the Declarations menu allows you to jump to a function/datatype whatever, type C-L to execute the code in another frame etc -- I'd say it was worth a look unless emacs brings you out in a rash.
PS. What the heck email client puts URLs in as footnotes?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://www.nabble.com/Arbitrary-precision--tf3700066.html#a10349446 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Anyway... long ramble over... Emacs isn't my operating system of choice. I prefer to use SciTE (which is *just* a text editor - as in, it doesn't also come with an integrated toaster and alarm clock). One SciTE window open, one command prompt pointing at the source folder... seems to work fairly well. Would be nice if SciTE would colourise Haskell syntax, but since Haskell is so absurdly hard to parse, I guess that's asking a lot. ;-)
SciTE is based on the Scintilla editor which comes with a lexer for Haskell. It's not particularly good, but it's better than nothing. If the latest version of SciTE doesn't support Haskell syntax highlighting then it should be very easy for the developers to add. /David

On 06/05/07, Andrew Coppin
Oh, by the way, thanks for the extra syntax. It's really annoying having to locate Notepad.exe on the start menu, type "import Blah", save it as "Thing.hs", open Windoze Explorer, locate Thing.hs, and then double-click it just so that I can try stuff out in GHCi...
Any reason you can't use :module Blah in GHCi? -- -David House, dmhouse@gmail.com

On Sun, 6 May 2007, Andrew Coppin wrote:
Greetings.
Haskell has arbitrary precision integers, in the form of the Integer type. Is there a type somewhere that implements arbitrary precision fractional values?
Whatever you want: http://haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number...
participants (7)
-
Andrew Coppin
-
Brandon S. Allbery KF8NH
-
David House
-
David Waern
-
Henning Thielemann
-
Jim Burton
-
Stefan O'Rear