Re: [Haskell-cafe] Guards (Was: Some random newbie questions)

2005-01-07 Thread Jon Cast
Henning Thielemann <[EMAIL PROTECTED]> wrote: > What about dropping Guards? :-) Are they necessary? Do they lead to > more readable source code? Absolutely. In Haskell's syntax, if-then-else-if interacts badly with do notation, and Haskell lacks a direct analogy to Lisp's cond. case () of ()

[Haskell-cafe] Re: Unicode: Hugs vs GHC (again) was: Re: Some random newbie questions

2005-01-07 Thread Ashley Yakeley
In article <[EMAIL PROTECTED] ft.com>, "Simon Marlow" <[EMAIL PROTECTED]> wrote: > True. Anyone care to take Hugs' implementation of the character class > functions and put it in GHC? There's extensive character property tables in code in

Preventing space leaks without seq (was: Re: [Haskell-cafe] Some random newbie questions)

2005-01-07 Thread Henk-Jan van Tuyl
L.S., Olaf <[EMAIL PROTECTED]> wrote: I'm constantly surprised hearing from so many people about their space problems. I cannot remember having space problems with my programs. I don't know what everybody else is doing wrong I do disagree with people recommending strictness annotations (seq etc).

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 11:00:27PM +0100, Tomasz Zielonka wrote: > Hmmm, TMVar's seem to be significantly (ie. 6 times) faster than MVars > in some simple tests :) > > Is it expected? If it is, we can reimplement MVars using STM, when STM becomes stable :) Best regards, Tomasz __

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 04:47:12PM +0100, Tomasz Zielonka wrote: > On Fri, Jan 07, 2005 at 04:55:05PM +0200, Einar Karttunen wrote: > > if we use IO as the signature then using the TMVar has few advantages over > > using an MVar. > > Yes, I think you are right here. Hmmm, TMVar's seem to be signi

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Sebastian Sylvan
On Fri, 7 Jan 2005 20:56:42 +0100, Sebastian Sylvan <[EMAIL PROTECTED]> wrote: > On Fri, 07 Jan 2005 15:31:10 +0200, Einar Karttunen > wrote: > > Hello > > > > What is the best way of doing an computation with a timeout? > > I like the approach taken in "Tackling the ackward squad": > I should

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Sebastian Sylvan
On Fri, 07 Jan 2005 15:31:10 +0200, Einar Karttunen wrote: > Hello > > What is the best way of doing an computation with a timeout? I like the approach taken in "Tackling the ackward squad": First a funcion which will "race" two IO computations against each other, returning the "winning" resul

[Haskell-cafe] The Implementation of Functional Programming Languages

2005-01-07 Thread Simon Peyton-Jones
I'm happy to announce that my out-of-print 1987 book, The Implementation of Functional Programming Languages is now available online at http://research.microsoft.com/%7Esimonpj/papers/slpj-book-1987/index.htm Very many thanks to Marnie Montgomery, who did all the work.

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Lennart Augustsson
Malcolm Wallace wrote: Lennart writes: What encoding(s) did hbc allow in source files? The docs only mention unicode characters inside character & string literals. The Java encoding, i.e., \u. Well, in that case, nhc98 also supports Unicode in source files, identically to hbc. Well, you have

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Malcolm Wallace
"Simon Marlow" <[EMAIL PROTECTED]> writes: > >> - Can the Char type hold the full range of Unicode characters? > >>This has been true in GHC for some time, and is now true in Hugs. > >>I don't think it's true in nhc98 (please correct me if I'm wrong). > > > > You're wrong :-). nhc98 has

[Haskell-cafe] Re: Implementing computations with timeout

2005-01-07 Thread Peter Simons
Einar Karttunen writes: > What is the best way of doing an computation with a timeout? At you'll find a very readable and straightforward implementation of a generic timeout function: type Timeout = Int timeout :: Timeout -> IO a -> IO (Maybe a) The function uses th

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 04:55:05PM +0200, Einar Karttunen wrote: > if we use IO as the signature then using the TMVar has few advantages over > using an MVar. Yes, I think you are right here. Best regards, Tomasz ___ Haskell-Cafe mailing list Haskell-Ca

Re: [Haskell-cafe] Guards (Was: Some random newbie questions)

2005-01-07 Thread Christian Maeder
Henning Thielemann wrote: What about dropping Guards? :-) Are they necessary? Do they lead to more readable source code? Do they lead to more efficient code? I could perfectly live without them up to now. I hardly need guards too, but their advantage is that they let pattern matching fail, resulti

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 04:55:05PM +0200, Einar Karttunen wrote: > > Isn't this buggy if fun just keeps working without throwing an exception > or using retry? I meant wholly inside STM There is not that much that you can do inside STM. This may be a problem if you want to wait for a genuine IO a

Re: [Haskell-cafe] Some random newbie questions

2005-01-07 Thread Ross Paterson
On Fri, Jan 07, 2005 at 08:49:32AM -0500, Paul Hudak wrote: > I taught our FP class this fall using Hugs, but in the end wish that I > had used GHC. There are lots of little reasons for this, but a big one > was a problem with unpredictable space utilization. I don't have the > examples at my

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 02:57:19PM +0100, Tomasz Zielonka wrote: > My guess is it would be something like this, however you may want to do it > differently to get better compositionality (withTimeout returns an IO action, > not a STM action): Maybe this will suffice, but I don't know if the delay

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Einar Karttunen
Tomasz Zielonka <[EMAIL PROTECTED]> writes: > import Control.Concurrent (forkIO, threadDelay) > import Control.Concurrent.STM > > withTimeout :: Int -> STM a -> IO (Maybe a) > withTimeout time fun = do > mv <- atomically newEmptyTMVar > tid <- forkIO $ do > threadDelay

Re: [Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 03:31:10PM +0200, Einar Karttunen wrote: > Hello > > What is the best way of doing an computation with a timeout? > > A naive implementation using two threads is easy to create - but > what is the preferred solution? > > withTimeout :: forall a. Int -> IO a -> IO (Maybe

RE: [Haskell-cafe] Unicode: Hugs vs GHC (again) was: Re: Some random newbie questions

2005-01-07 Thread Simon Marlow
On 07 January 2005 13:01, Dimitry Golubovsky wrote: > Lennart Augustsson wrote: >> Simon Marlow wrote: >> >>> Here's a summary of the state of Unicode support in GHC and other >>> compilers. There are several aspects: >>> >>> - Can the Char type hold the full range of Unicode characters? >>>

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Lennart Augustsson
Simon Marlow wrote: Many years ago, hbc claimed to be the only compiler with support for this. What encoding(s) did hbc allow in source files? The docs only mention unicode characters inside character & string literals. The Java encoding, i.e., \u. -- Lennart

Re: [Haskell-cafe] Some random newbie questions

2005-01-07 Thread Paul Hudak
Benjamin Pierce wrote: OK, I'm taking the plunge and using Haskell in a course I'm teaching this semester. To get ready, I've been doing quite a bit of Haskell programming myself, and this has raised a few questions... * What are the relative advantages of Hugs and GHC, beyond the obvious (Hugs

RE: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Simon Marlow
On 07 January 2005 12:30, Malcolm Wallace wrote: > "Simon Marlow" <[EMAIL PROTECTED]> writes: > >> Here's a summary of the state of Unicode support in GHC and other >> compilers. There are several aspects: >> >> - Can the Char type hold the full range of Unicode characters? >>This has been

[Haskell-cafe] Implementing computations with timeout

2005-01-07 Thread Einar Karttunen
Hello What is the best way of doing an computation with a timeout? A naive implementation using two threads is easy to create - but what is the preferred solution? withTimeout :: forall a. Int -> IO a -> IO (Maybe a) withTimeout time fun = do mv <- newEmptyMVar tid <- forkIO (fun >>= tr

Re: [Haskell-cafe] Unicode: Hugs vs GHC (again) was: Re: Some random newbie questions

2005-01-07 Thread Dimitry Golubovsky
Hi, Lennart Augustsson wrote: Simon Marlow wrote: Here's a summary of the state of Unicode support in GHC and other compilers. There are several aspects: - Can the Char type hold the full range of Unicode characters? This has been true in GHC for some time, and is now true in Hugs. I don't

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-07 Thread Malcolm Wallace
"Simon Marlow" <[EMAIL PROTECTED]> writes: > Here's a summary of the state of Unicode support in GHC and other > compilers. There are several aspects: > > - Can the Char type hold the full range of Unicode characters? >This has been true in GHC for some time, and is now true in Hugs. >I

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-07 Thread Lennart Augustsson
Simon Marlow wrote: Here's a summary of the state of Unicode support in GHC and other compilers. There are several aspects: - Can the Char type hold the full range of Unicode characters? This has been true in GHC for some time, and is now true in Hugs. I don't think it's true in nhc98 (plea

Re: [Haskell-cafe] Some random newbie questions

2005-01-07 Thread Ketil Malde
[EMAIL PROTECTED] writes: > I'm constantly surprised hearing from so many people about their space > problems. I cannot remember having space problems with my programs. I > don't know what everybody else is doing wrong :-) At least two common cases. Extracting compact data structures from large

RE: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-07 Thread Simon Marlow
Here's a summary of the state of Unicode support in GHC and other compilers. There are several aspects: - Can the Char type hold the full range of Unicode characters? This has been true in GHC for some time, and is now true in Hugs. I don't think it's true in nhc98 (please correct me if I'

Re: [Haskell-cafe] Some random newbie questions

2005-01-07 Thread O . Chitil
> * What are the relative advantages of Hugs and GHC, beyond the obvious > (Hugs > is smaller and easier for people not named Simon to modify, while GHC is > a > real compiler and has the most up-to-date hacks to the type checker)? > Do > people generally use one or the other for everything,

[Haskell-cafe] Guards (Was: Some random newbie questions)

2005-01-07 Thread Henning Thielemann
On Fri, 7 Jan 2005, Simon Peyton-Jones wrote: > | * As far as I can determine, there is no way to check pattern matches > for > | exhaustiveness. Coming from OCaml, this feels like losing a > significant > | safety net! How do people program so as not to be getting dynamic > match > | fai

RE: [Haskell-cafe] Some random newbie questions

2005-01-07 Thread Simon Peyton-Jones
| * As far as I can determine, there is no way to check pattern matches for | exhaustiveness. Coming from OCaml, this feels like losing a significant | safety net! How do people program so as not to be getting dynamic match | failures all the time? GHC has -fwarn-incomplete-patterns and -f

RE: [Haskell-cafe] The implementation of Functional

2005-01-07 Thread Simon Peyton-Jones
The online-readable copy is all ready to go. I'm just awaiting a final "ok" from Marnie and I'll announce it. For a paper copy we'll await John's Cafepress efforts. Much thanks to both Marnie and John. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Be