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: QuickCheck (Lee Duhem)
2. Re: QuickCheck (Brent Yorgey)
3. cabal install readline: Missing HSReadlline.h on Mac OS X
Leopard (man)
4. Empty list Exception (Chic?o Fernandes Junior)
5. Re: Empty list Exception (Chic?o Fernandes Junior)
6. Re: Re: Empty list Exception (Sean Bartell)
7. Re: Re: Empty list Exception (Chic?o Fernandes Junior)
----------------------------------------------------------------------
Message: 1
Date: Sun, 24 May 2009 11:59:26 +0800
From: Lee Duhem <[email protected]>
Subject: Re: [Haskell-beginners] QuickCheck
To: Thomas Friedrich <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Sun, May 24, 2009 at 11:47 AM, Thomas Friedrich <[email protected]> wrote:
>
> Does anyone know why the now version of QuickCheck is not compatible with
> the old one?
You should ask the authors directly :-)
lee
------------------------------
Message: 2
Date: Sun, 24 May 2009 10:57:57 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] QuickCheck
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sat, May 23, 2009 at 11:47:06PM -0400, Thomas Friedrich wrote:
>
> Does anyone know why the now version of QuickCheck is not compatible with
> the old one?
Well, the new version is close to a complete rewrite. It's
differently organized, has a number of new features, etc.; the fact
that it's incompatible with 1.2 is a feature, not a bug. =)
That said, I assume there are ways with version 2 to do the same
things you were doing with 1.2, but they might have different names
and so on. Unfortunately I'm not terribly familiar with the
differences; you'll just have to dig around in the documentation.
-Brent
------------------------------
Message: 3
Date: Sun, 24 May 2009 17:49:08 +0200
From: man <[email protected]>
Subject: [Haskell-beginners] cabal install readline: Missing
HSReadlline.h on Mac OS X Leopard
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
I got this error installing readline (I really was installing lambdabot, it
depends on readline):
Configuring readline-1.0.1.0...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for GNUreadline.framework... checking for readline... yes
checking for rl_readline_version... yes
checking for rl_begin_undo_group... yes
checking for rl_erase_empty_line... yes
checking for rl_free_undo_list... yes
checking for rl_completion_word_break_hook in -lreadline... yes
configure: creating ./config.status
config.status: creating config.mk
config.status: creating readline.buildinfo
config.status: creating include/HsReadlineConfig.h
cabal: Missing dependency on a foreign library:
* Missing header file: HsReadline.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
cabal: Error: some packages failed to install:
lambdabot-4.2.2.1 depends on readline-1.0.1.0 which failed to install.
readline-1.0.1.0 failed during the configure step. The exception was:
exit: ExitFailure 1
This is on Leopard, with GNUreadline installed. As far as I see, HSReadline
is an internally generated header in readline-1.0.1.0, how possibly cabal
may be missing it? I got nothing with google, only that readline seems to be
problematic on OSX.
PS: I just installed cabal-install in ~/.cabal, it installs other packages
without fuss (gsl-random being an exception, but it may be the GSL part...).
Any help welcome!
--
happy hacking... man
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090524/f5835ab2/attachment-0001.html
------------------------------
Message: 4
Date: Sun, 24 May 2009 16:13:18 -0300
From: Chic?o Fernandes Junior <[email protected]>
Subject: [Haskell-beginners] Empty list Exception
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hello!
I'm starting programming in haskell and I got some problems
running in GHCi (version 6.8.2) a module I've wrote.
The following ...
--The first string is the name and the second is the user ID, just for test
>
type User = (String, String, Integer)
>
> users = [("Marcelo Castro", "1234", 2),
> ("Joao Vicente Claudino", "1235", 2),
> ("Wilson Brandao", "1236", 2),
> ("Humberto Teixeira", "1237", 2),
> ("Luiz Gonzaga", "1238", 2),
> ("Severino Dias", "1239", 2),
> ("Hermeto Pascoal", "1234", 2)]
>
> checkUser :: User -> [User] -> Bool
> checkUser user userList
> = if (head (filter (\userParse -> userParse == user) userList)) ==
> user
> then True
> else False
>
>
> userRegistration :: User -> [User] -> [User]
> userRegistration user list
> | checkUser user list = list
> | not(checkUser user list) = (user : list)
> | otherwise = []
>
--
____________________________________________________________________________
Francisco Borges "Chicão" Junior
..........................................................................................
http://pedepinico.blogspot.com
..........................................................................................
"Quem de boa vontade carrega o difícil, também carrega o menos difícil..."
Lao Tsé - Tao Te Ching
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090524/10ee5b31/attachment-0001.html
------------------------------
Message: 5
Date: Sun, 24 May 2009 16:17:16 -0300
From: Chic?o Fernandes Junior <[email protected]>
Subject: [Haskell-beginners] Re: Empty list Exception
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Sorry, I send it accidently. I did't finish my question.
Anyway, when I run in GHCi:
userRegistration ("Joao Claudino","1240",2) users
>
It gives me the exception:
*** Exception: Prelude.head: empty list
>
Can anyone explain to me why the exception is thown and what should I do to
fix it?
Thanks
--
____________________________________________________________________________
Francisco Borges "Chicão" Junior
..........................................................................................
http://pedepinico.blogspot.com
..........................................................................................
"Quem de boa vontade carrega o difícil, também carrega o menos difícil..."
Lao Tsé - Tao Te Ching
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090524/c82826b2/attachment-0001.html
------------------------------
Message: 6
Date: Sun, 24 May 2009 15:35:10 -0400
From: Sean Bartell <[email protected]>
Subject: Re: [Haskell-beginners] Re: Empty list Exception
To: Chic?o Fernandes Junior <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
When you use filter in this case, it's checking for users that are the same
as ("Joao Claudino", "1240", 2). There aren't any in the list, so filter
returns []. You can't use head on [], because there's no first element.
Other notes about your code:
- if x then True else False is the same as just x.
- The otherwise case for userRegistration can never be reached.
I would write it more like this:
checkUser user userList = elem user userList
userRegistration user list
| checkUser user list = list
| otherwise = user:list
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090524/c593ff74/attachment-0001.html
------------------------------
Message: 7
Date: Sun, 24 May 2009 23:14:42 -0300
From: Chic?o Fernandes Junior <[email protected]>
Subject: Re: [Haskell-beginners] Re: Empty list Exception
To: Joel Neely <[email protected]>, [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thanks everyone, for the answers.
I didn't knew the *elem* function. That will make my life easier.
For the sake of simplicity, I changed the code to a shorter
*userRegistration* function, eliminating the *checkUser* function:
userRegistration user list
> | elem user list = list
> | otherwise = user:list
>
It did worked fine.
I'm glad that I can count with this list in my learning process.
Thanks again.
--
____________________________________________________________________________
Francisco Borges "Chicão" Junior
..........................................................................................
http://pedepinico.blogspot.com
..........................................................................................
"Quem de boa vontade carrega o difícil, também carrega o menos difícil..."
Lao Tsé - Tao Te Ching
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090524/e07ea037/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 11, Issue 17
*****************************************