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.  programming with Error monad (Dennis Raddle)
   2.  literate programming (Dennis Raddle)
   3. Re:  literate programming (Brandon Allbery)


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

Message: 1
Date: Sat, 1 Sep 2012 12:59:19 -0700
From: Dennis Raddle <[email protected]>
Subject: [Haskell-beginners] programming with Error monad
To: Haskell Beginners <[email protected]>
Message-ID:
        <CAKxLvoqwL+Ht84-8J2B7PHpAxEJ4Buhvv-=bakfpetwzgul...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I recently completed a large project and started another one. The first
project was about processing music, in particular taking MusicXML and/or
Sibelius files (Sibelius is a music notation program) and producing MIDI
files according to the specifications I wanted.

The second project is about algorithmic music composition.

To handle errors in the first project, I used "throw" to throw exceptions.

Now I am using the Error monad... actually a combination of ErrorT and
State. (In the state I hold a random generator for use in algorithms that
require pseudo-randomness.)

I notice two things now. The first thing is that I can catch and rethrow
errors to provide annotation about the context. It's like getting a stack
trace automatically every time there is an error. I realize now this makes
it easier to debug, and during my first project I spent a lot of time
debugging that might have been avoidable. (I confess I never could figure
out the ghci debugger, which might have helped.)

The second thing is that there seems to be less laziness. Every statement
in a do statement seems to execute even if I don't use result. I think. I
would have to do some more experiments, but that is what it looks like
right now. That is another good thing for debugging... less laziness (and
maybe guaranteed order of execution too?) means it's easier to understand
what the program is attempting to do.

Does this seem correct?

Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120901/cc2dac98/attachment-0001.htm>

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

Message: 2
Date: Sat, 1 Sep 2012 15:46:55 -0700
From: Dennis Raddle <[email protected]>
Subject: [Haskell-beginners] literate programming
To: Haskell Beginners <[email protected]>
Message-ID:
        <cakxlvoqtgbjs88rwfqms6pnuues4foo7+9dcg-deptobmc4...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Does literate programming in haskell (.lhs) support the idea in Knuth's WEB
of using aliases for blocks of code? In other words doing something like

main = do
  <part 1>
  <part 2>

<part 1> === putStrLn "foo"
<part 2> === putStrLn "bar"

(except I don't know what the actual syntax is)

-Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120901/a217bb5f/attachment-0001.htm>

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

Message: 3
Date: Sat, 1 Sep 2012 19:35:59 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] literate programming
To: Dennis Raddle <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
        <CAKFCL4Wdm=nHV-XQsRFvYKGhncBmxp=-hk4hkgf81jkoymu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Sat, Sep 1, 2012 at 6:46 PM, Dennis Raddle <[email protected]>wrote:

> Does literate programming in haskell (.lhs) support the idea in Knuth's
> WEB of using aliases for blocks of code? In other words doing something like
>
> main = do
>   <part 1>
>   <part 2>
>
> <part 1> === putStrLn "foo"
> <part 2> === putStrLn "bar"
>
> (except I don't know what the actual syntax is)


No, and it's not as necessary in Haskell as it was in Pascal because it's
easier (and preferred) to break programs up into smaller functions anyway.
 So your <part 1> is just part1, and the definition of part1 follows later.
 (Consider that we don't throw around state in variables quite as wontonly;
and when we *do* need to, we can stuff it in a state monad.)

-- 
brandon s allbery                                      [email protected]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120901/b07c774f/attachment-0001.htm>

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

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


End of Beginners Digest, Vol 51, Issue 3
****************************************

Reply via email to