Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Efficient sieve of erastothenes,     for solving project
      euler problem #10? (Kurt Hutchinson)
   2. Re:  Trouble with formatting,     Real World Haskell example
      (Robert Kosara)
   3. Re:  Possible to update Haskell syntax (Brent Yorgey)
   4. Re:  Trouble with formatting, Real World  Haskell example
      (Brent Yorgey)
   5. Re:  GTK + Reactive (Bas van Dijk)
   6.  Help in Haskell (Andre Paulo Machado)
   7. Re:  Possible to update Haskell syntax (Brandon S. Allbery KF8NH)
   8.  Re: Help in Haskell (Benjamin L.Russell)


----------------------------------------------------------------------

Message: 1
Date: Mon, 24 Nov 2008 09:56:33 -0500
From: "Kurt Hutchinson" <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Efficient sieve of erastothenes,       for
        solving project euler problem #10?
To: "Malcolm Reynolds" <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 23, 2008 at 5:28 PM, Malcolm Reynolds
<[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I'm attempting to learn Haskell by going through the project euler
> problems. Number 10,
> http://projecteuler.net/index.php?section=problems&id=10 , involves
> summing prime numbers. It's easy in terms of coding something up that
> works, but I'm having a lot of trouble getting decent performance.

I realize that these early prime number related Euler problems are
about writing your own efficient prime generator, so you may want to
ignore this message for now. But later on when the problems just
happen to involve primes, but the generator is kind of assumed, you
may want to check out this collection:

http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip

The file "ONeillPrimes.hs" contains what is, I think, generally
considered to be one of the fastest pure-Haskell prime generators. In
particular, this program:

> import ONeillPrimes ( primesToLimit )
>
> main = ( print . sum . primesToLimit ) 2000000

Gives the correct answer on my machine in about 0.3 seconds.


------------------------------

Message: 2
Date: Mon, 24 Nov 2008 09:56:44 -0500
From: "Robert Kosara" <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Trouble with formatting,       Real World
        Haskell example
To: "Kurt Hutchinson" <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Kurt,
  that's a good idea, that also groups the elements in the where much
better.

  Thanks everybody for your responses (I don't think I've responded to the
list so far).


Regards,

Robert

On Mon, Nov 24, 2008 at 9:23 AM, Kurt Hutchinson <[EMAIL PROTECTED]>wrote:

> On Sun, Nov 23, 2008 at 12:10 AM, Steven Ashley
> <[EMAIL PROTECTED]> wrote:
> > The contents of the do block must be indented at-least as much as
> > mainWith on the previous line.
>
> > main = mainWith myFunction
> > ....where mainWith function = do
> > ....................args <- getArgs
>
>
> This is the reason that I format 'where' clauses like so:
>
> main = mainWith myFunction
> ....where
> ....mainWith f = do
> ........args <- getArgs
>
> etc. I think one more line of vertical space is worth all of the
> horizontal space you end up saving.
>
> Kurt
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20081124/89b1be3f/attachment-0001.htm

------------------------------

Message: 3
Date: Mon, 24 Nov 2008 12:12:53 -0500
From: Brent Yorgey <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Possible to update Haskell syntax
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

In general, the point is that there is already a 'whitespace operator'
in Haskell corresponding to function application.  So it would be
ambiguous for whitespace to also indicate separation of list elements.

Also, I rarely need to write explicit lists of any length, so I think
you will find that having to write an explicit comma in between
elements is not that much of an annoyance.

With all that said, you may also find the new 'quasiquoting'
functionality in GHC 6.10.1 to be of interest.  Quasiquoting allows
you to specify arbitrary parsers for specially quoted strings.  In
particular, you could implement a list quasiquoter so that you could
write something like

  [ls| 1 2 3 4 |]

which could parse to the list [1,2,3,4].  I haven't had a chance to
play around with the quasiquoting stuff myself yet, however, so I
don't have a good idea of how difficult this would be.

-Brent

On Sun, Nov 23, 2008 at 06:00:17PM +1300, Steven Ashley wrote:
> Hi cm,
> 
> An ambiguity arises when you have a list containing functions. For
> instance consider:
> 
> fmap ($3) [id id id id]
> 
> Cheers,
> 
> Steven
> 
> 
> 2008/11/23 cm <[EMAIL PROTECTED]>:
> > I'm very interested in learning Haskell, but one frustration is that lists
> > always require commas.  As an example [1,2,3,4] is a valid expression, but
> > [1 2 3 4] is not.
> >
> > In this ideal world, another example would be that [(fun1 3 4) 7] would be a
> > valid expression and be a two-element list equivalent to [fun1 3 4, 7].
> >
> > If what I am suggesting is syntactically possible and doesn't break more
> > advanced features of the language that I (as a beginner) am unaware of, I'm
> > interested in patching the open source for my own use (as well as others who
> > might want it).
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners


------------------------------

Message: 4
Date: Mon, 24 Nov 2008 12:22:28 -0500
From: Brent Yorgey <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Trouble with formatting, Real World
        Haskell example
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

On Sat, Nov 22, 2008 at 09:53:37PM -0500, Robert Kosara wrote:
> 
> main = mainWith myFunction
>     where mainWith function = do
>         args <- getArgs
>         case args of
>             [input, output] -> interactWith function input output
>             _ -> putStrLn "Usage: Interact inputFile outputFile"
> 
>         myFunction = id
> 

I think the point is that this 'where' block is supposed to introduce
two definitions: one for 'mainWith' and one for 'myFunction'.  The
'myFunction = id' should not be part of the do-block (it wouldn't make
sense, and isn't even syntactically correct).

The layout rule is this: the column of the first thing following the
'do' determines the indentation for the rest of the do-block.  The first
line which is indented *less* than that is the first line following
the end of the do-block.  So:


   do foo
      bar
      baz
     not part of the do-block!

or:

   mainWith function = do
       start of the do-block (doesn't necessarily need to be indented past 
'mainWith')
       another line in the do-block
    this is not part of the do-block

I would indent the code like so:

> main = mainWith myFunction
>     where mainWith function = do
>               args <- getArgs
>               case args of
>                   [input, output] -> interactWith function input output
>                   _ -> putStrLn "Usage: Interact inputFile outputFile"
> 
>           myFunction = id

Also, you should never use tabs -- it's hard to predict how they will
be interpreted by the layout rule, and haskell files using tabs are
also non-portable, in the sense that if you send it to someone else
they may have different tab settings, etc.  It should be possible to
tell your favorite editor to automatically convert tabs into spaces.

-Brent


------------------------------

Message: 5
Date: Tue, 25 Nov 2008 01:28:15 +0100
From: "Bas van Dijk" <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] GTK + Reactive
To: "Levi Stephen" <[EMAIL PROTECTED]>
Cc: [email protected], [EMAIL PROTECTED]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

CCing this to the Reactive mailinglist.
See: http://www.haskell.org/mailman/listinfo/reactive

Bas

On Mon, Nov 24, 2008 at 1:00 PM, Levi Stephen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to set up a simple program combining Reactive and GTK. I have the
> program below so far, but mainQuit is never called. After looking at a
> couple of adapters I tried adding the commented out line, but this didn't
> work for me.
>
> I'm sure I've probably missed something, but I'm not sure what.
>
> Thanks,
> Levi
>
> main = do
>  initGUI
>
>  clock <- makeClock
>
>  (windowDestroy, sink) <- makeEvent clock
>
>  w <- windowNew
>  w `onDestroy` sink ()
>  widgetShowAll w
>
>  -- forkE (tSync clock) $ quitOnDestroy windowDestroy
>
>  mainGUI
>
> quitOnDestroy :: Event () -> Event (IO ())
> quitOnDestroy e = fmap (const mainQuit) e
>
> tSync :: Clock TimeT-> ITime -> IO ()
> tSync clock t = sleepPast (cGetTime clock) (exact t)
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>


------------------------------

Message: 6
Date: Mon, 24 Nov 2008 05:04:12 -0200
From: "Andre Paulo Machado" <[EMAIL PROTECTED]>
Subject: [Haskell-beginners] Help in Haskell
To: [email protected], [EMAIL PROTECTED]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Hi folks..... Somebody could help me, please?

Please, I would like a help in haskell programming, because I have with
following question:

I need to create a list of strings, like as a graph.
See:

initiaList = [ ("BSB,"SSA"),
                   ("CNF","SSA"),
                   ("CNF","GIG"),
                   ("CNF","GRU"),
                   ("GIG","CNF"),
                   ("GIG","GRU"),
                   ("GRU","BSB"),
                   ("GRU","GIG"),
                   ("GRU","CNF"),
                   ("SSA","CNF") ]

With this list above, I will create a function that returns a path with max
number of links:
example:

maxLink = 4 (result until 4)

command:   myFunction "BSB"  "GRU" 4
result:          1st Option:   BSB -> SSA -> CNF -> GRU
                    2nd Option:  BSB -> SSA -> CNF -> GIG -> GRU
----------------------------------------------------------------------------
command:   myFunction "BSB"  "GRU" 3
result:          1st Option:   BSB -> SSA -> CNF -> GRU
----------------------------------------------------------------------------

How do this?
I'm waiting from you,
thank you so much.

Andre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20081124/5af12ad8/attachment-0001.htm

------------------------------

Message: 7
Date: Tue, 25 Nov 2008 01:27:39 -0500
From: "Brandon S. Allbery KF8NH" <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Possible to update Haskell syntax
To: Brent Yorgey <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On 2008 Nov 24, at 12:12, Brent Yorgey wrote:
> In general, the point is that there is already a 'whitespace operator'
> in Haskell corresponding to function application.  So it would be
> ambiguous for whitespace to also indicate separation of list elements.


The other generality I'd add is that Haskell isn't Scheme, and it's  
best to get used to it.  (Although there is Liskell if you're feeling  
weird.)

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university    KF8NH




------------------------------

Message: 8
Date: Tue, 25 Nov 2008 17:11:29 +0900
From: Benjamin L.Russell <[EMAIL PROTECTED]>
Subject: [Haskell-beginners] Re: Help in Haskell
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

This looks like a homework question.  While we are all here to help
you figure out a solution, it would be unethical just to give you a
solution to a homework problem; rather, we are here to help you figure
out the solution yourself.

As such, first, please follow the homework help procedure outlined in
"Homework help - HaskellWiki" (see
http://www.haskell.org/haskellwiki/Homework_help) (substitute
"haskell-beginners or haskell-cafe" for "haskell-cafe," and just
ignore the part about the existence of "stupid questions"--there is no
such thing as a "stupid question"; however, there are such things as
appropriate questions and inappropriate questions, and in order for us
to help you appropriately in this context, you need to show us more
specifically what you have done and where you are stuck, so that we
can provide help that would be appropriate in this context).

Specifically, please follow the following procedure first:

>   1.  Read the problem carefully and make sure you understand what is being 
> asked of you.
>   2. If you can't solve the whole problem, try breaking the problem down into 
> parts and solving those parts.
>   3. If you can't write it in Haskell, try writing it in English (or your 
> native language) first.
>   4. If you can't write code, try at least writing a type signature.
>   5. Look through the libraries provided by Haskell, particularly those parts 
> which have been pointed out to you in class or in your course notes. There 
> may be something there which helps you. 

If you are still stuck, then it might be useful to follow the
following steps from the procedure listed on the above-mentioned
homework help page:

>   4. Try to make your question as specific as possible. Say what problem (or 
> subproblem) you are stuck on as succinctly as you can. If the original 
> homework question is long, don't copy it verbatim (though if it's available 
> on the web, a link couldn't hurt).
>   5. Say what you've done so far, and include code. People are much more 
> likely to help you fix your incorrect code than write correct code for you. 
> Moreover, if the problem is that you don't understand something, your 
> incorrect code will probably reflect this, and fixing your misunderstanding 
> is much more valuable than fixing your code. 

In the above-mentioned procedure, the more detail you provide, the
more helpful we can be in our hints.

-- Benjamin L. Russell

On Mon, 24 Nov 2008 05:04:12 -0200, "Andre Paulo Machado"
<[EMAIL PROTECTED]> wrote:

>Hi folks..... Somebody could help me, please?
>
>Please, I would like a help in haskell programming, because I have with
>following question:
>
>I need to create a list of strings, like as a graph.
>See:
>
>initiaList = [ ("BSB,"SSA"),
>                   ("CNF","SSA"),
>                   ("CNF","GIG"),
>                   ("CNF","GRU"),
>                   ("GIG","CNF"),
>                   ("GIG","GRU"),
>                   ("GRU","BSB"),
>                   ("GRU","GIG"),
>                   ("GRU","CNF"),
>                   ("SSA","CNF") ]
>
>With this list above, I will create a function that returns a path with max
>number of links:
>example:
>
>maxLink = 4 (result until 4)
>
>command:   myFunction "BSB"  "GRU" 4
>result:          1st Option:   BSB -> SSA -> CNF -> GRU
>                    2nd Option:  BSB -> SSA -> CNF -> GIG -> GRU
>----------------------------------------------------------------------------
>command:   myFunction "BSB"  "GRU" 3
>result:          1st Option:   BSB -> SSA -> CNF -> GRU
>----------------------------------------------------------------------------
>
>How do this?
>I'm waiting from you,
>thank you so much.
>
>Andre



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 5, Issue 14
****************************************

Reply via email to