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: Global variables (Yitzchak Gale)
2. version of base in Haskell Platform (Dennis Raddle)
3. Re: version of base in Haskell Platform (Ertugrul Soeylemez)
4. Re: Global variables (Ertugrul Soeylemez)
5. GOTCHA! OpenGL window behaviour is mis-spelled... (Sean Charles)
6. Re: GOTCHA! OpenGL window behaviour is mis-spelled...
(Jack Henahan)
----------------------------------------------------------------------
Message: 1
Date: Thu, 30 Jun 2011 17:05:15 +0300
From: Yitzchak Gale <[email protected]>
Subject: Re: [Haskell-beginners] Global variables
To: Michael Xavier <[email protected]>
Cc: [email protected], ARJANEN Lo?c Jean-David
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
ARJANEN Lo?c Jean-David wrote:
>> For a pet project I need a global counter, giving how many times a
>> given function was called. What would you use for that purpose ?
Michael Xavier wrote:
> I tend to use Control.Monad.State for stateful stuff like this. It is found
> in the mtl package
> http://hackage.haskell.org/package/mtl-2.0.1.0
I agree that this is a good approach.
If the only state you need is this, it might be easier just
to add the counter as an additional parameter to your function,
and return its incremented value as part of your return type.
For example, you can return a tuple (v, n) where v is the value
you were returning before and n is the updated counter.
If you also need other kinds of state, or if adding the counter
complicates the types throughout your program,
then the State monad is the way to go.
Regards,
Yitz
------------------------------
Message: 2
Date: Thu, 30 Jun 2011 10:49:23 -0700
From: Dennis Raddle <[email protected]>
Subject: [Haskell-beginners] version of base in Haskell Platform
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I just installed the latest Haskell Platform on Windows XP. Then I tried to
install the musicxml package, and it says it needs base 3.something. How do
I find out what version of base comes with a version of the Haskell
Platform?
Thanks,
Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110630/726f4551/attachment-0001.htm>
------------------------------
Message: 3
Date: Thu, 30 Jun 2011 19:59:03 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] version of base in Haskell Platform
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Dennis Raddle <[email protected]> wrote:
> I just installed the latest Haskell Platform on Windows XP. Then I
> tried to install the musicxml package, and it says it needs base
> 3.something. How do I find out what version of base comes with a
> version of the Haskell Platform?
Run the following command:
cabal info base
If you can't find the cabal command, make sure that your PATH is correct
and contains the path to the binaries installed by the HP.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
Message: 4
Date: Thu, 30 Jun 2011 20:19:44 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] Global variables
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Yitzchak Gale <[email protected]> wrote:
> > I tend to use Control.Monad.State for stateful stuff like this. It
> > is found in the mtl package
> > http://hackage.haskell.org/package/mtl-2.0.1.0
>
> I agree that this is a good approach.
>
> If the only state you need is this, it might be easier just to add the
> counter as an additional parameter to your function, and return its
> incremented value as part of your return type. For example, you can
> return a tuple (v, n) where v is the value you were returning before
> and n is the updated counter.
>
> If you also need other kinds of state, or if adding the counter
> complicates the types throughout your program, then the State monad is
> the way to go.
I agree that this is a good approach for this particular case, if the
counter is really attached to the given computation and is not
interesting elsewhere.
However for state in general there is an approach, which is often
forgotten: implicit configurations. This allows you to pull state
around without mentioning it explicitly in any way, somewhat related to
the ImplicitParams extension, but saner and with a sound theoretical
foundation. The advantage is that the state is encapsulated in a type
class and thus you can have parallel state threads, invisibly pulling
around state attached to certain type constructors.
The paper "Functional Pearl: Implicit configurations" by Oleg Kiselyov
and Chung-chieh Shan introduces you to this abstraction.
Greets
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
Message: 5
Date: Thu, 30 Jun 2011 20:38:27 +0100
From: Sean Charles <[email protected]>
Subject: [Haskell-beginners] GOTCHA! OpenGL window behaviour is
mis-spelled...
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
This caught me out for several frustrating minutes until I finally saw
the problem...
package: Graphics.UI.GLUT.Begin
data ActionOnWindowClose has three constructors, and I wanted the third
one which I glanced at and then spelled it how I knew it *should* be:
ContinueExecution
which gave me an error, and finally I realised that as an English word
it is in fact spelled incorrectly in the code, like so:
ContinueExectuoin
HTML Link:
http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/Graphics-UI-GLUT-Begin.html#v:actionOnWindowClose
Is this one of those "accepted things" as in, too difficult to change
because it will break stuff or could it be changed ?
All the best,
Sean.
------------------------------
Message: 6
Date: Thu, 30 Jun 2011 15:45:31 -0400
From: Jack Henahan <[email protected]>
Subject: Re: [Haskell-beginners] GOTCHA! OpenGL window behaviour is
mis-spelled...
To: Sean Charles <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Seems like something that _should_ be changed, either way. Contact the
developer, I guess. http://www.haskell.org/haskellwiki/User:SvenPanne
On Jun 30, 2011, at 3:38 PM, Sean Charles wrote:
> This caught me out for several frustrating minutes until I finally saw the
> problem...
>
> package: Graphics.UI.GLUT.Begin
>
> data ActionOnWindowClose has three constructors, and I wanted the third one
> which I glanced at and then spelled it how I knew it *should* be:
>
> ContinueExecution
>
> which gave me an error, and finally I realised that as an English word it is
> in fact spelled incorrectly in the code, like so:
>
> ContinueExectuoin
>
> HTML Link:
> http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/Graphics-UI-GLUT-Begin.html#v:actionOnWindowClose
>
>
> Is this one of those "accepted things" as in, too difficult to change because
> it will break stuff or could it be changed ?
>
> All the best,
> Sean.
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
====
"Computer Science is no more about computers than astronomy is about
telescopes."
-- Edsger Dijkstra
====
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 398E692F.asc
Type: application/x-apple-msg-attachment
Size: 24295 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110630/a9ba32d0/attachment.bin>
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 881 bytes
Desc: This is a digitally signed message part
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110630/a9ba32d0/attachment.pgp>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 36, Issue 85
*****************************************