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: System.Process and ghc 6.8.2 (Conrad Meyer)
2. Re: System.Process and ghc 6.8.2 (Erik de Castro Lopo)
3. Re: Is ghc 6.8.2 useful? (Sterling Clover)
4. The case expression (Erik de Castro Lopo)
5. Re: The case expression (Brent Yorgey)
6. Re: The case expression (Erik de Castro Lopo)
7. Re: The case expression (David Morse)
8. Re: The case expression (Daniel Seidel)
----------------------------------------------------------------------
Message: 1
Date: Thu, 22 Jan 2009 15:03:37 -0800
From: Conrad Meyer <[email protected]>
Subject: Re: [Haskell-beginners] System.Process and ghc 6.8.2
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Thursday 22 January 2009 02:28:41 pm Erik de Castro Lopo wrote:
> Conrad Meyer wrote:
> > Why do this extra work instead of simply upgrading to 6.8.3?
>
> Mainly because 6.8.2 is installed on my Ubuntu system using a
> pre-compiled package (including a bunch of pre-compiled libraries).
> I much prefer to use the the native packaging system because most
> of the time it works so much better than anything else.
>
> Also, the "extra work" became a few minor tweaks to this code:
>
> http://www.cse.unsw.edu.au/~dons/code/newpopen/System/Process/Run.hs
>
> Cheers,
> Erik
So nag the Ubuntu ghc maintainer about being several versions behind. Or if
they're actually not several versions behind, you're just using an old
version of ubuntu, install a copy of ghc from a newer version of ubuntu.
--
Conrad Meyer <[email protected]>
------------------------------
Message: 2
Date: Fri, 23 Jan 2009 10:14:14 +1100
From: Erik de Castro Lopo <[email protected]>
Subject: Re: [Haskell-beginners] System.Process and ghc 6.8.2
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Conrad Meyer wrote:
> So nag the Ubuntu ghc maintainer about being several versions behind. Or if
> they're actually not several versions behind, you're just using an old
> version of ubuntu, install a copy of ghc from a newer version of ubuntu.
I'm running the current latest release of Ubuntu and using the latest
ghc they offer.
The Ubuntu people just grab their version from Debian. I'm actually
tracking the Debian Haskell mailing list and just in the last week
there was an announcement of ghc-6.10.1 going into the experimental
repository. Then they need to compile all the libraries with the new
compiler.
I'm thinking of grabbing the debian source package from Debian
experimental and building it on Ubuntu.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Always code as if the person who ends up maintaining your
code will be a violent psychopath who knows where you live."
-- Martin Golding
------------------------------
Message: 3
Date: Thu, 22 Jan 2009 19:03:33 -0500
From: Sterling Clover <[email protected]>
Subject: Re: [Haskell-beginners] Is ghc 6.8.2 useful?
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
The libraries as of 6.8.2 are here:
http://www.haskell.org/ghc/docs/6.8.2/html/libraries/
The regex library should be part of extralibs, which appears to come
standard with debian's ghc package. There are also better regex libraries
available from Hackage. There is indeed a new System.Process API, which you
may be able to install from hackage. Otherwise, for most purposes, the old
one works just fine. As for exitSuccess, as the documentation notes, it is
simply "exitWith ExitSuccess", so I wouldn't be too concerned at not being
able to use it.
In general 6.8.2 should be very useable still.
Cheers,
S.
On Thu, Jan 22, 2009 at 4:59 AM, Erik de Castro Lopo
<[email protected]<mle%[email protected]>
> wrote:
> Thomas Davie wrote:
>
> > Are you sure that you're finding things that are unavailable in
> > 6.8.2?
>
> Specifically the things I found missing in just the last couple of
> hours are:
>
> - module Text.Regex.Posix
> - functions readProcess/readProcessWithExitCode from System.Process
> - function exitSuccess from System.Exit
>
> > There's been very little change to the APIs exposed to
> > beginners since then.
>
> I must admit I am jumping in at the deep end, but I do have 4 years of
> pretty extensive Ocaml coding under my belt.
>
> > It may be that you're not importing the module
> > required
>
> Haskell's modules are quite similar to Ocaml's but I'm pretty confident
> I have this under control.
>
> > Sorry if I just taught my granny to suck eggs.
>
> I'm not your granny :-)
>
> > If you are doing this
> > and really are coming up against APIs that aren't in 6.8, then yes,
> > you need to upgrade your compiler.
>
> I'll take that as an ACK.
>
> > There's no real disadvantage to
> > doing this though, except possibly that you lose support for one or
> > two libraries that are taking a while to update (gtk2hs springs to
> > mind).
>
> Ouch. I'm pretty attached to the debian packaging system on my Debian
> and Ubuntu systems and really don't like to install non-packaged
> binaries or source. On top of that I like to use existing libraries
> whereever possible and that means installing these from source as
> well.
>
> I might have to look into cabal-debian.
>
> Cheers,
> Erik
> --
> -----------------------------------------------------------------
> Erik de Castro Lopo
> -----------------------------------------------------------------
> Gambling(n): A discretionary tax on those asleep during high school
> maths.
> _______________________________________________
> 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/20090122/6b43ca84/attachment-0001.htm
------------------------------
Message: 4
Date: Fri, 23 Jan 2009 14:01:41 +1100
From: Erik de Castro Lopo <[email protected]>
Subject: [Haskell-beginners] The case expression
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Hi all,
Ocaml's match .. with expression (very similar to Haskell's case)
allows multiple matches for a single result (naive example):
let f x =
match x with
| 0 -> "zero"
| 1 | 3 | 5 | 7 -> "odd"
| 2 | 4 | 6 | 8 -> "even"
_ -> "bad number"
Is there a similar thing in Haskell? At the moment I have to do
something like :
f x =
case x of
0 -> "zero"
1 -> "odd"
3 -> "odd"
5 -> "odd"
7 -> "odd"
2 -> "even"
4 -> "even"
6 -> "even"
8 -> "even"
_ -> "bad number"
Cheers,
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"One of our programming maxims is "make illegal states unrepresentable"
by which we mean that if a given collection of values constitute an
error, then it is better to arrange for that collection of values to be
impossible to represent within the constraints of the type system."
-- Yaron Minsky
http://www.haskell.org/sitewiki/images/0/03/TMR-Issue7.pdf
------------------------------
Message: 5
Date: Thu, 22 Jan 2009 22:11:20 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] The case expression
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Fri, Jan 23, 2009 at 02:01:41PM +1100, Erik de Castro Lopo wrote:
> Hi all,
>
> Ocaml's match .. with expression (very similar to Haskell's case)
> allows multiple matches for a single result (naive example):
>
> let f x =
> match x with
> | 0 -> "zero"
> | 1 | 3 | 5 | 7 -> "odd"
> | 2 | 4 | 6 | 8 -> "even"
> _ -> "bad number"
>
> Is there a similar thing in Haskell?
There isn't, but in this particular case (and in many similar cases)
you could always do something like this, using guards:
let f x | x == 0 -> "zero"
| x `elem` [1,3,5,7] -> "odd"
| x `elem` [2,4,6,8] -> "even"
| otherwise -> "bad number"
-Brent
------------------------------
Message: 6
Date: Fri, 23 Jan 2009 14:17:00 +1100
From: Erik de Castro Lopo <[email protected]>
Subject: Re: [Haskell-beginners] The case expression
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
David Morse wrote:
> So you could really hammer it with blunt force:
>
> case x of
> 0 -> "zero"
> n | n `elem` [1,3,5,7] -> "odd"
> | n `elem` [2, 4, 6, 8] -> "even"
> | otherwise -> "bad number"
Ah, that's was what I was after. Thanks.
> By the way, zero is even. http://en.wikipedia.org/wiki/Zero_is_even
I did warn people this was a naive example. Did I really need to
make people aware this it was a *silly, completely contrived and
possibly incorrect* example ;-).
Cheers,
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Therapists typically base the nuttiness of a patient on the
strength of their convictions, on which basis this 43,000 word
opus alone stands as a kind of testament to Bill's (Gates)
madness." - The Register
------------------------------
Message: 7
Date: Thu, 22 Jan 2009 22:08:40 -0500
From: David Morse <[email protected]>
Subject: Re: [Haskell-beginners] The case expression
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Jan 22, 2009 at 10:01 PM, Erik de Castro Lopo
<[email protected]> wrote:
>
> Hi all,
>
> Ocaml's match .. with expression (very similar to Haskell's case)
> allows multiple matches for a single result (naive example):
>
> let f x =
> match x with
> | 0 -> "zero"
> | 1 | 3 | 5 | 7 -> "odd"
> | 2 | 4 | 6 | 8 -> "even"
> _ -> "bad number"
>
> Is there a similar thing in Haskell? At the moment I have to do
> something like :
>
> f x =
> case x of
> 0 -> "zero"
> 1 -> "odd"
> 3 -> "odd"
> 5 -> "odd"
> 7 -> "odd"
> 2 -> "even"
> 4 -> "even"
> 6 -> "even"
> 8 -> "even"
> _ -> "bad number"
Well you can guard each clause:
case x of
0 -> "zero"
n | even n -> "even"
| odd n -> "odd"
| otherwise -> "bad number"
Still not quite exactly what you've got.
So you could really hammer it with blunt force:
case x of
0 -> "zero"
n | n `elem` [1,3,5,7] -> "odd"
| n `elem` [2, 4, 6, 8] -> "even"
| otherwise -> "bad number"
By the way, zero is even. http://en.wikipedia.org/wiki/Zero_is_even
------------------------------
Message: 8
Date: Fri, 23 Jan 2009 08:41:27 +0100
From: Daniel Seidel <[email protected]>
Subject: Re: [Haskell-beginners] The case expression
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Erik de Castro Lopo wrote:
> Hi all,
>
> Ocaml's match .. with expression (very similar to Haskell's case)
> allows multiple matches for a single result (naive example):
>
> let f x =
> match x with
> | 0 -> "zero"
> | 1 | 3 | 5 | 7 -> "odd"
> | 2 | 4 | 6 | 8 -> "even"
> _ -> "bad number"
>
> Is there a similar thing in Haskell? At the moment I have to do
> something like :
>
> f x =
> case x of
> 0 -> "zero"
> 1 -> "odd"
> 3 -> "odd"
> 5 -> "odd"
> 7 -> "odd"
> 2 -> "even"
> 4 -> "even"
> 6 -> "even"
> 8 -> "even"
> _ -> "bad number"
>
> Cheers,
> Erik
>
Hi Erik,
you can use guards like this:
f x
| x == 0 = "zero"
| x `elem` [1,3,5,7] = "odd"
| x `elem` [2,4,6,8] = "even"
| otherwise = "bad number"
daniel.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seideld.vcf
Type: text/x-vcard
Size: 255 bytes
Desc: not available
Url :
http://www.haskell.org/pipermail/beginners/attachments/20090123/0e2b5837/seideld.vcf
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 7, Issue 16
****************************************