Some good-hearted criticism

Juan Carlos Arevalo Baeza
Wed, 27 Jun 2001 19:56:03 -0700

At 03:26 PM 6/27/2001 -0600, Alastair David Reid wrote:

>Other useful options that Windows (and Unix?) people may not know about are:
>   --enable-timer            enable evaluation timing
>   --enable-stack-dumps      enable stack dump on stack overflow

    That might have helped...

>   --enable-only98           make Hugs Haskell 98 only

    Can't you already toggle this in a normal build? -98 and +98.

>   --with-readline           support fancy command line editing
>   --with-preprocessor       allow use of a preprocessor

    Thanx. But all those are only available if you recompile, right? Why 
are they disabled by default? Because they affect performance?

>The useful ones are documented in the file hugs98/Install - but you
>usually only read that if you install from source.  Now that most
>people get their Hugs in binary form for Windows or Linux, it might be
>worth mentioning these features more prominently on the web page or in
>the Hugs documentation.

    They would still be useless without recompiling, but yes, it would be 
good to "let people know" :)

>Many people would code that more trickily by consing x onto the front
>of r and then returning the reverse of r:
> > manynot :: Parser p inp => p inp v -> p inp a -> p inp ([v],Maybe a)
> > manynot s p = mn [] p where mn r p = force $ do a <- p
> >                                                  return (reverse r,Just a)
> >                                               +++
> >                                               do x <- s
> >                                                  mn (x:r) p
> >                                               +++
> >                                               return (reverse r,Nothing)

    Tricky :)

>This avoids quadratic cost from the repeated appends (N appends with
>time of each one proportional to length of list).  Both approaches are
>equally strict.  I think both require stack space proportional to the
>list length though I could be wrong about the repeated appends (too
>hot to figure it out).

    Hmmm... It seems to me that this would cause the same amount of stack 
hit, yes. At least, accessing the "head" of the list would mean recursively 
running through the whole list.

    Seems to me like Haskell could do with a better list primitive, where 
you can pattern-match on either side (with two constructors, so to speak). 
Making it a primitive would allow the underlying implementation to actually 
use looping if appropriate when pattern-matching. It would, at least, 
lessen the possibility of running out of stack space when dealing with lists.

    Anyway, I just did a little test. My example had gotten fixed because 
the multi-line comment is discarded. It still blew up if I tried to print 
it out. With your modifications, though, it does run till the end in Hugs, 
so there's some stack savings there. I'm not sure I understand why. In 
fact, I just tried making the whole comment longer and longer, and it ends 
up running out of heap space, not stack space, of all things. Seems like 
"reverse" doesn't do its work recursively after all. Could it be a primitive?

>Less trickily, you could use one of Chris Okasaki's data structures
>that guarantees fast append to the tail of the list.

    Is that like an add-on primitive or is it just normal Haskell? In 
either case, maybe it's done in a way similar as I was describing above...

    And thanks to you and all the others. This is great :)


Juan Carlos "JCAB" Arevalo Baeza    |
Senior Technology Engineer          |
Ronin Entertainment                 | ICQ: 101728263
                        (my opinions are only mine)
JCAB's Rumblings is so off-line O:-(