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. Bug or Intended behavior? ( Exception: stack overflow ) (Seung)
2. Re: Processing individual csv line ([email protected])
3. Re: Bug or Intended behavior? ( Exception: stack overflow )
(Daniel Fischer)
4. Re: Looking for some guidance to installing GHCI on MAC
(patricklynch)
5. Re: Looking for some guidance to installing GHCI on MAC
(JETkoten)
----------------------------------------------------------------------
Message: 1
Date: Mon, 24 Jan 2011 10:59:15 +0000 (UTC)
From: Seung Soo, Ha <[email protected]>
Subject: [Haskell-beginners] Bug or Intended behavior? ( Exception:
stack overflow )
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
my setup: phenom II quadcore, 4GB mem Ubuntu Maverick
While implementing my own reverse in "99 haskell questions",
I made the following mistake:
(Caution: stack over flow causing code below)
reverse'::[a] -> [a]
reverse' [] = []
reverse' [x] = [x]
reverse' xs = last xs : init (reverse' xs)
The last line is the wrong part. It should be
reverse' xs = last xs : reverse' (init xs)
anyway, the original code seems to cause an infinite recursion
by repeating the last part forever. When I try this out on ghci:
*Main> reverse' [1,2,3,4,5]
[5*** Exception: stack overflow
*Main>
The problem is, unless I manually exit ghci, the "stack" does not seem to be
freed (garbage collected?) and memory remains fully occupied by ghci.
I tried waiting a bit, but it stayed the same.
Is this expected behavior? Shouldn't the GC kick in?
Is this orthogonal of the GC?
I think this would help me understand haskell and GHC much better.
------------------------------
Message: 2
Date: Mon, 24 Jan 2011 17:42:20 +0530
From: "[email protected]" <[email protected]>
Subject: Re: [Haskell-beginners] Processing individual csv line
To: Shakthi Kannan <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
You could also create a wrapper function that accepts [[String]] and let it
deal with the inner lists. If it is pure function, then you can say *Right
r -> return (<your function> r)*. This would wrap the return value from the
function in IO monad.
On Mon, Jan 24, 2011 at 3:44 PM, Shakthi Kannan <[email protected]>wrote:
> Hi,
>
> I am trying to parse a .csv file and process the individual lines.
> Here is some code snippet (based on RWH Chapter 16 [1]):
>
> === test.hs ===
>
> import Text.ParserCombinators.Parsec
> import System.Environment (getArgs)
>
> parseCSV :: String -> Either ParseError [[String]]
> parseCSV input = parse csvFile "(unknown)" input
>
> main = do
> do c <- getContents
> case parse csvFile "(stdin)" c of
> Left e -> do putStrLn "Error parsing input:"
> print e
> Right r -> mapM_ print r
>
> === END ===
>
> Given an input file foo.csv:
>
> a,b,c
> d,e,f
> g,h,i
>
> and running the above test.hs using:
>
> $ runghc test.hs < foo.csv
>
> I get the following output:
>
> ["a,b,c"]
> ["d,e,f"]
> ["g,h,i"]
>
> Instead of using mapM_ print r, how can I obtain and pass each of the
> above lists (for example, ["a,b,c"]) to another function for
> processing?
>
> Appreciate any inputs,
>
> Thanks!
>
> SK
>
> [1] RWH. Using Parsec.
> http://book.realworldhaskell.org/read/using-parsec.html
>
> --
> Shakthi Kannan
> http://www.shakthimaan.com
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
Regards
Lakshmi Narasimhan T V
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110124/9e3cc69d/attachment-0001.htm>
------------------------------
Message: 3
Date: Mon, 24 Jan 2011 13:49:58 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Bug or Intended behavior? (
Exception: stack overflow )
To: [email protected]
Cc: "Seung Soo, Ha" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Monday 24 January 2011 11:59:15, Seung Soo, Ha wrote:
> my setup: phenom II quadcore, 4GB mem Ubuntu Maverick
>
> While implementing my own reverse in "99 haskell questions",
>
> I made the following mistake:
> (Caution: stack over flow causing code below)
>
>
> reverse'::[a] -> [a]
> reverse' [] = []
> reverse' [x] = [x]
> reverse' xs = last xs : init (reverse' xs)
>
> The last line is the wrong part. It should be
> reverse' xs = last xs : reverse' (init xs)
>
> anyway, the original code seems to cause an infinite recursion
> by repeating the last part forever.
Yes. In
loop :: [Int]
loop = 1 : init loop
the evaluation goes
loop = 1 : init loop
-- now it must be checked whether init loop
-- a) gives an error because loop is empty (which it isn't, so no error)
-- b) is empty because loop is one element long
-- c) is nonempty because loop contains at least two elements
~> 1 : init (1 : init loop)
-- same problem in the parentheses
~> 1 : init (1 : init (1 : init loop))
-- ad infinitum
To see whether loop has a second element, we first must see whether loop
has a second element.
the structure is the same as for your last line of reverse', only there you
have function calls instead of named values (1, loop).
> When I try this out on ghci:
>
>
> *Main> reverse' [1,2,3,4,5]
> [5*** Exception: stack overflow
> *Main>
>
> The problem is, unless I manually exit ghci, the "stack" does not seem
> to be freed (garbage collected?) and memory remains fully occupied by
> ghci.
GHC used to not return any memory it has allocated to the OS (in case it is
needed again later), thus ghci wouldn't return any memory either.
I think? that as of GHC-7, GHC now returns memory to the OS after memory
usage has dropped (not immediately, of course, it waits until memory usage
has been lower for a bit).
? I may be wrong, it may have already been in some 6.12.
With ghci-7.0.1, after ^C-ing the computation at 24% memory, according to
top, it dropped to 4%, didn't wait to check whether more memory would be
released later.
>
> I tried waiting a bit, but it stayed the same.
>
> Is this expected behavior?
I think so. At least for GHC < 7.
> Shouldn't the GC kick in?
> Is this orthogonal of the GC?
The GC would free the memory but keep it for the process to reuse.
If you can run space consuming things afterwards without ghci's memory
usage going up, that's what's happening.
> I think this would help me understand haskell and GHC much better.
>
------------------------------
Message: 4
Date: Mon, 24 Jan 2011 09:35:27 -0500
From: "patricklynch" <[email protected]>
Subject: Re: [Haskell-beginners] Looking for some guidance to
installing GHCI on MAC
To: "'JETkoten'" <[email protected]>, <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Thanks for the 'heads up'.
I got a 'free' Apple ID but it didn't work with the Apple download of
Xcode...the Apple ID that I received from them was
'[email protected]' which is my email address...this gives the
invalid message...
I've notified Apple of this and am awaiting an answer from them...
Good day
-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of JETkoten
Sent: Monday, January 24, 2011 5:37 AM
To: [email protected]
Subject: Re: [Haskell-beginners] Looking for some guidance to installing
GHCI on MAC
Xcode is needed on the Mac to install *anything* that's not already a
ready made (pre-compiled binary) program. Once you've got Xcode
installed, it really does get easier!
It is different than the PC because the Mac is using Xcode to convert
the GHC and other Haskell platform files from the source code that
people can read to a complied binary program that the computer can read
and that can run on your Mac. On the PC what you downloaded and
installed was already compiled before you downloaded it.
Once you get your free developer.apple.com account you then look for the
link for Xcode and pick the one for your version of OSX (10.4 or 10.5 or
10.6).
Download the file and when it finishes you can just double click it on
the download window and it'll run the installer, or at least take you to
the downloaded installer in whatever folder it is in so you can then
double click installer file and make it run. I forget which way it works
right now, but one of those will work.
It'll then have you agree to the software license, and ask for your
system password.
Write it in, then wait a while for it to finish. It'll tell you when
it's done... and after that you can try to install the Haskell platform
again and it should work.
This is the beginner list: "Here, there is no such thing as a 'stupid
question.'" Any other problems with your install? Post them back to the
list. You don't have to give up on it... keep at it and people here will
help you through.
On 1/23/11 5:20 PM, patricklynch wrote:
> ...i tried the March 2010 installation on the MAC and I get the same
> result...if there is a requirement for Xcode, shouldn't it be listed in
the
> Installation Instructions... I tried another installation but it too
> required Xcode...
>
> ...again, I was able to install GHC on a PC and was able to install HUGs
on
> the Mac...
>
> ...really frustrating... I'm not going to pay Apple $99, so I may have to
> give up on the Mac for a while - bummer...
>
> -----Original Message-----
> From: patricklynch [mailto:[email protected]]
> Sent: Sunday, January 23, 2011 4:44 PM
> To: 'Antoine Latter'
> Cc: 'Wes Morgan'; '[email protected]'
> Subject: RE: [Haskell-beginners] Looking for some guidance to installing
> GHCI on MAC
>
> ...sorry for being a 'klutz' - but I'm new to the mac too...
> ...i'm guessing that I have Xcode installed...i see an X icon that has an
> X11 label - when I click it, it displays nothing...bummer...
> ...since I was able to install Hugs I'm guessing that Xcode is
> installed...however, I have no way of knowing if this is true...and Apple
> wants $99 for a Developer fee, bummer...I was not given an installation
> disk...
>
> I went to the site: haskage.haskell.org\platform\mac.html...
> It gives me a three step installation procedure...
> ...the 1st deletes any previous installation of GHC - this worked...
> ...the 2nd gets me to a screen that states Standard install on "Macintosh
> HD"; with a message: click Install...{however, the Install Button can not
be
> clicked}...this is as far as I can get...
>
> -----Original Message-----
> From: Antoine Latter [mailto:[email protected]]
> Sent: Sunday, January 23, 2011 2:55 PM
> To: patricklynch
> Cc: Wes Morgan; [email protected]
> Subject: Re: [Haskell-beginners] Looking for some guidance to installing
> GHCI on MAC
>
> The problem I had at first with the Haskell Platform installer was
> that I didn't have Xcode installed.
>
> This should be on one of the OS X install discs, I think. You can also
> download it from Apple:
>
> http://developer.apple.com/technologies/xcode.html
>
> It might be easier if you could send us the error message you're getting.
>
> Antoine
>
> On Sun, Jan 23, 2011 at 2:18 PM, patricklynch<[email protected]>
> wrote:
>> ...i tried to use the installation for Mac at Haskell.org, but it gives
me
>> an error message [something like: call your software vendor]...
>>
>> ...i tried the Homebrew, see email below, but it wants my Apple
Developer
>> id...i don't have one...
>>
>> ...i installed it on my pc and all it took was a single keystroke...
>> ...i installed Hugs on my Mac without any problem..
>>
>> ...i'd appreciate any help, I really need to work with ghc on my mac
>>
>> Go Jets
>>
>> -----Original Message-----
>> From: [email protected]
[mailto:[email protected]]
>> On Behalf Of Wes Morgan
>> Sent: Sunday, January 23, 2011 7:36 AM
>> To: [email protected]
>> Subject: Re: [Haskell-beginners] Looking for some guidance to installing
>> GHCI on MAC
>>
>> I just used Homebrew (http://mxcl.github.com/homebrew/). Once that's
>> installed, 'brew install ghc' gets you GHC, GHCi, cabal, etc.
>>
>> Wes
>>
>> On Jan 23, 2011, at 6:00 AM, "[email protected]"
>> <[email protected]> wrote:
>>
>>> Re: [Haskell-beginners] Looking for some guidance to
>>> installing GHCI on MAC
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
> _______________________________________________
> 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: 5
Date: Mon, 24 Jan 2011 10:26:00 -0500
From: JETkoten <[email protected]>
Subject: Re: [Haskell-beginners] Looking for some guidance to
installing GHCI on MAC
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
You're welcome. While you wait for Apple, why not try one more time?
Go to this page:
http://developer.apple.com/devcenter/download.action?path=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg
It will ask you for your Apple ID and password, put in
[email protected]
for user and add your password.
If your login is not working, that might be why you get the invalid
message? If so, click the blue *Forgot Password?* link and it will reset
your password for you and email you to let you make a new one so that
you can then log in and get the file I linked above.
After you log in, it should pop up a window and ask to Save or Cancel.
Choose Save, wait for the download to finish, open the .dmg by double
clicking and the rest should work.
You don't need the Apple ID for installing Xcode just your OSX system
password...
I'm not sure exactly what part of the install isn't working with your
Xcode install, but I think you're pretty close to getting it working.
On 1/24/11 9:35 AM, patricklynch wrote:
> Thanks for the 'heads up'.
>
> I got a 'free' Apple ID but it didn't work with the Apple download of
> Xcode...the Apple ID that I received from them was
> '[email protected]' which is my email address...this gives the
> invalid message...
>
> I've notified Apple of this and am awaiting an answer from them...
>
> Good day
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of JETkoten
> Sent: Monday, January 24, 2011 5:37 AM
> To: [email protected]
> Subject: Re: [Haskell-beginners] Looking for some guidance to installing
> GHCI on MAC
>
> Xcode is needed on the Mac to install *anything* that's not already a
> ready made (pre-compiled binary) program. Once you've got Xcode
> installed, it really does get easier!
>
> It is different than the PC because the Mac is using Xcode to convert
> the GHC and other Haskell platform files from the source code that
> people can read to a complied binary program that the computer can read
> and that can run on your Mac. On the PC what you downloaded and
> installed was already compiled before you downloaded it.
>
> Once you get your free developer.apple.com account you then look for the
> link for Xcode and pick the one for your version of OSX (10.4 or 10.5 or
> 10.6).
>
> Download the file and when it finishes you can just double click it on
> the download window and it'll run the installer, or at least take you to
> the downloaded installer in whatever folder it is in so you can then
> double click installer file and make it run. I forget which way it works
> right now, but one of those will work.
>
> It'll then have you agree to the software license, and ask for your
> system password.
>
> Write it in, then wait a while for it to finish. It'll tell you when
> it's done... and after that you can try to install the Haskell platform
> again and it should work.
>
> This is the beginner list: "Here, there is no such thing as a 'stupid
> question.'" Any other problems with your install? Post them back to the
> list. You don't have to give up on it... keep at it and people here will
> help you through.
>
> On 1/23/11 5:20 PM, patricklynch wrote:
>> ...i tried the March 2010 installation on the MAC and I get the same
>> result...if there is a requirement for Xcode, shouldn't it be listed in
> the
>> Installation Instructions... I tried another installation but it too
>> required Xcode...
>>
>> ...again, I was able to install GHC on a PC and was able to install HUGs
> on
>> the Mac...
>>
>> ...really frustrating... I'm not going to pay Apple $99, so I may have to
>> give up on the Mac for a while - bummer...
>>
>> -----Original Message-----
>> From: patricklynch [mailto:[email protected]]
>> Sent: Sunday, January 23, 2011 4:44 PM
>> To: 'Antoine Latter'
>> Cc: 'Wes Morgan'; '[email protected]'
>> Subject: RE: [Haskell-beginners] Looking for some guidance to installing
>> GHCI on MAC
>>
>> ...sorry for being a 'klutz' - but I'm new to the mac too...
>> ...i'm guessing that I have Xcode installed...i see an X icon that has an
>> X11 label - when I click it, it displays nothing...bummer...
>> ...since I was able to install Hugs I'm guessing that Xcode is
>> installed...however, I have no way of knowing if this is true...and Apple
>> wants $99 for a Developer fee, bummer...I was not given an installation
>> disk...
>>
>> I went to the site: haskage.haskell.org\platform\mac.html...
>> It gives me a three step installation procedure...
>> ...the 1st deletes any previous installation of GHC - this worked...
>> ...the 2nd gets me to a screen that states Standard install on "Macintosh
>> HD"; with a message: click Install...{however, the Install Button can not
> be
>> clicked}...this is as far as I can get...
>>
>> -----Original Message-----
>> From: Antoine Latter [mailto:[email protected]]
>> Sent: Sunday, January 23, 2011 2:55 PM
>> To: patricklynch
>> Cc: Wes Morgan; [email protected]
>> Subject: Re: [Haskell-beginners] Looking for some guidance to installing
>> GHCI on MAC
>>
>> The problem I had at first with the Haskell Platform installer was
>> that I didn't have Xcode installed.
>>
>> This should be on one of the OS X install discs, I think. You can also
>> download it from Apple:
>>
>> http://developer.apple.com/technologies/xcode.html
>>
>> It might be easier if you could send us the error message you're getting.
>>
>> Antoine
>>
>> On Sun, Jan 23, 2011 at 2:18 PM, patricklynch<[email protected]>
>> wrote:
>>> ...i tried to use the installation for Mac at Haskell.org, but it gives
> me
>>> an error message [something like: call your software vendor]...
>>>
>>> ...i tried the Homebrew, see email below, but it wants my Apple
> Developer
>>> id...i don't have one...
>>>
>>> ...i installed it on my pc and all it took was a single keystroke...
>>> ...i installed Hugs on my Mac without any problem..
>>>
>>> ...i'd appreciate any help, I really need to work with ghc on my mac
>>>
>>> Go Jets
>>>
>>> -----Original Message-----
>>> From: [email protected]
> [mailto:[email protected]]
>>> On Behalf Of Wes Morgan
>>> Sent: Sunday, January 23, 2011 7:36 AM
>>> To: [email protected]
>>> Subject: Re: [Haskell-beginners] Looking for some guidance to installing
>>> GHCI on MAC
>>>
>>> I just used Homebrew (http://mxcl.github.com/homebrew/). Once that's
>>> installed, 'brew install ghc' gets you GHC, GHCi, cabal, etc.
>>>
>>> Wes
>>>
>>> On Jan 23, 2011, at 6:00 AM, "[email protected]"
>>> <[email protected]> wrote:
>>>
>>>> Re: [Haskell-beginners] Looking for some guidance to
>>>> installing GHCI on MAC
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
> _______________________________________________
> 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/20110124/2e4f7c17/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 31, Issue 26
*****************************************