Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  finding the cause of an error (here head: empty list)
      (David McBride)
   2. Re:  finding the cause of an error (here head: empty list)
      (Kim-Ee Yeoh)
   3. Re:  cabal install local troubles (osx) (luc taesch)
   4. Re:  finding the cause of an error (here head: empty list)
      (Emmanuel Touzery)
   5. Re:  [IO String] to IO [String] (Ovidiu D)
   6.  lazy mapM (Ovidiu D)
   7. Re:  lazy mapM (Karl Voelker)


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

Message: 1
Date: Sun, 31 Mar 2013 13:17:11 -0400
From: David McBride <toa...@gmail.com>
Subject: Re: [Haskell-beginners] finding the cause of an error (here
        head: empty list)
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <can+tr42lvouhybyi5z5psj_cckskuczpuojydn2cajr-wis...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

There is a safe package on hackage that has variations on head, headMay
which uses maybe, headNote which allows you to put a more descriptive error
should it fail, and headDef which allows you to specify a default, should
it fail.

But the most common way of dealing with it is not to use head except in
extremely simple cases.  You can grep some substantial codebases like yesod
and see maybe two or three actual heads in the code.  People tend to use
pattern matching on lists or case statements on the list.


On Sun, Mar 31, 2013 at 11:42 AM, Nathan H?sken <nathan.hues...@posteo.de>wrote:

> Hey,
>
> I have written a program which, when executed produces:
>
>   Main: Prelude.head: empty list
>
> Now, I can go through my program and replace all "head" with
>
>   (\a -> trace ("<line-nr>: length=" ++ (show (length a))) a)
>
> Actually, I already did that, and by this I found the error.
> But I wonder if there would have been an easier way?
> Has anyone any debug advice how I could find out which call to "head"
> causes this without so much typing work?
>
> Thanks!
> Nathan
>
> ______________________________**_________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130331/c0ec865f/attachment-0001.htm>

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

Message: 2
Date: Mon, 1 Apr 2013 02:05:05 +0700
From: Kim-Ee Yeoh <k...@atamo.com>
Subject: Re: [Haskell-beginners] finding the cause of an error (here
        head: empty list)
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <capy+zdqvyoxrdn8djoxf7gnxf3xkp746sq3lksrfw05mnzy...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Apr 1, 2013 at 12:17 AM, David McBride <toa...@gmail.com> wrote:
> People tend to use pattern matching on lists or case statements on the list.

Yes, and activate -Wall to detect places where the pattern matching
isn't covering all cases.

Modulo the actual exception, head is equivalent to

head (x:xs) = x

Notice the absence of a "head []" definition.

-- Kim-Ee



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

Message: 3
Date: Sun, 31 Mar 2013 22:41:08 +0200
From: luc taesch < luc.tae...@gmail.com>
Subject: Re: [Haskell-beginners] cabal install local troubles (osx)
To: beginners@haskell.org
Message-ID: <kja710$rb7$1...@ger.gmane.org>
Content-Type: text/plain; charset=iso-8859-1; format=flowed

On Osx 10.8, I recently run into 32/64 issues.
so I was advised to reinstall HP 2012.4 64, which I did.
to be sure, I wiped ( moved) my ./~cabal

after resintallation I was suprised to find it nearly empty, and all 
files are now into ~/Library/Haskell
( and the Path is to be updated accrodingly,as mentionned in the install)

note this only occur when your ~/.cabal is non existing at installation time
as documented below


http://www.haskell.org/haskellwiki/Mac_OS_X_Common_Installation_Paths


Haskell Platform 2011.2.0.0 (March 2011) and later uses this layout and 
sets up cabal to use it for built packages. On new installs, if you 
didn't already have a ~/.cabal/config file, then it is set up by 
default. Otherwise, the config file for this layout is placed in 
~/.cabal/config.platform and you can manually move it over, or 
incorporate it into your existing config file.

On 2013-03-27 06:16:53 +0000, Miro Karpis said:

> please, can you help me with following. I have installed haskell on mac 
> from the package. When I check cabal -V I can see 1.14.0?
> That is because the cabal is loading from /Library/Haskell/bin.
> 
> After that I run 'cabal install cabal-install', I get following output:
> 
> Installing executable(s) in
> /Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin
> Updating documentation index /Users/miro/Library/Haskell/doc/index.html
> 
> So the new version of cabal is installed in another place. When I 
> install new package via cabal, it uses the 1.14.0 version. I have tried 
> to copy the new 1.16.0.2 version to bin, but that just didn't help 
> because the new packages have been installed somewhere else.
> 
> Please what is the proper way to fix this?
> 
> many thanks,
> miro






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

Message: 4
Date: Sun, 31 Mar 2013 23:03:31 +0200
From: Emmanuel Touzery <etouz...@gmail.com>
Subject: Re: [Haskell-beginners] finding the cause of an error (here
        head: empty list)
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <CAC42Rem9RNAGRdXGpRc9U8MUpcKWdPGw+=cmwc4pnk5kbxr...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I asked more or less the same question in august 2012.

as I have gained more experience with Haskell, the problem has become less
important and I think it will be the same with you. But there is a better
solution than Maybe and others, haskell can give you a stack trace if you
compile with profiling enabled:

http://marc.info/?t=135220245600002&r=1&w=4

I now make sure to compile all my libraries with profiling enabled, just in
case I may need it...

emmanuel


On Sun, Mar 31, 2013 at 5:42 PM, Nathan H?sken <nathan.hues...@posteo.de>wrote:

> Hey,
>
> I have written a program which, when executed produces:
>
>   Main: Prelude.head: empty list
>
> Now, I can go through my program and replace all "head" with
>
>   (\a -> trace ("<line-nr>: length=" ++ (show (length a))) a)
>
> Actually, I already did that, and by this I found the error.
> But I wonder if there would have been an easier way?
> Has anyone any debug advice how I could find out which call to "head"
> causes this without so much typing work?
>
> Thanks!
> Nathan
>
> ______________________________**_________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130331/ba17aec4/attachment-0001.htm>

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

Message: 5
Date: Mon, 1 Apr 2013 00:49:48 +0300
From: Ovidiu D <ovidiud...@gmail.com>
Subject: Re: [Haskell-beginners] [IO String] to IO [String]
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <CAKVsE7sBVRNmBaafzG8C7qR=q_mrgkdrooechh5dltn3u_u...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

My problem with interact was that it doesn't give me the line when the user
hits enter but instead it gives me all the lines at once when stdin is
closed (unless I did something wrong)

The other problem is that I want to stop the command processing when the
user types the command "exit" and it seems interact can't do that.


On Sun, Mar 31, 2013 at 2:52 PM, Lyndon Maydwell <maydw...@gmail.com> wrote:

> Depending on what you're doing with the lines, it may be worth checking
> out the `interact` function as well :-)
>
>
> On Sun, Mar 31, 2013 at 7:42 PM, Kim-Ee Yeoh <k...@atamo.com> wrote:
>
>> On Sun, Mar 31, 2013 at 5:19 PM, Ovidiu D <ovidiud...@gmail.com> wrote:
>> > I would like to make this function to have the signature
>> > f : IO [String]
>> > ...such that I can get rid of the IO monad and pass the pure string
>> list to
>> > the processing function.
>>
>> You could use:
>>
>> getContents >>= lines :: IO [String]
>>
>> -- Kim-Ee
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130401/35fc4c3d/attachment-0001.htm>

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

Message: 6
Date: Mon, 1 Apr 2013 02:26:17 +0300
From: Ovidiu D <ovidiud...@gmail.com>
Subject: [Haskell-beginners] lazy mapM
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <cakvse7ssfgf0jn0dvty8xa8m8hxygtjcu0pfqw4ftu6bzmw...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi again,

Given the following code:

g :: IO String -> IO String

f :: [IO String] -> IO [ String ]
f = mapM g

The implementation of f is wrong because I would like to:
1. Make f behave lazy
Its input list is made of lines read from stdin and I want it to process
lines one by one as they are entered by the user.

2. Implement  f such that it stops consuming items from the input list when
the input item meets some condition. For example:
isExit item = ("exit" == item)

I tried to implement my own custom iteration by recursion but I got stuck
in the combination of IO and list monads.

Any help is appreciated.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130401/4177aece/attachment-0001.htm>

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

Message: 7
Date: Sun, 31 Mar 2013 17:29:01 -0700
From: Karl Voelker <ktvoel...@gmail.com>
Subject: Re: [Haskell-beginners] lazy mapM
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <CAFfow0z4g0iVeG5DLNvsD85REdnEsFtOCsoYfdF=ntonc8n...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Sun, Mar 31, 2013 at 4:26 PM, Ovidiu D <ovidiud...@gmail.com> wrote:

> I tried to implement my own custom iteration by recursion but I got stuck
> in the combination of IO and list monads.
>

I think this is a good way to start. If you post the code you had, I'm sure
you'll be able to get some help understanding what went wrong.

-Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130331/cdd001c1/attachment.htm>

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 58, Issue 1
****************************************

Reply via email to