Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/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.  help to learn recursion (Roelof Wobben)
   2. Re:  help to learn recursion
      (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   3. Re:  help to learn recursion (Alexey Shmalko)
   4.  AMQP and nested exception handlers (Alex)
   5.  Reading, Processing, and Writing I/O (Dananji Liyanage)
   6. Re:  Reading, Processing, and Writing I/O (Kim-Ee Yeoh)
   7. Re:  AMQP and nested exception handlers (Kostiantyn Rybnikov)


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

Message: 1
Date: Mon, 11 May 2015 17:44:04 +0200
From: Roelof Wobben <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] help to learn recursion
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

I want to learn Haskell but still have some problems on using recursion. 
On simple tasks I can make it work but for example the tower of Hanoi I 
cannot figure out how things are can be solved.

Is there a book or tutorial with exercises so I can pratice it?

Roelof


---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
http://www.avast.com



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

Message: 2
Date: Mon, 11 May 2015 21:19:36 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] help to learn recursion
Message-ID:
        <CAJbEW8PW250W-d9HeGnEz5NYBnpJ-5H8k3N=7odzixhhglz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

A good way to practice is to implement all functions that you know from
Data.List. Most (all?) can be implemented using recursion, and then a
subsequent excercise would be to refactor them using foldr, foldl etc.

On 11 May 2015 at 21:14, Roelof Wobben <[email protected]> wrote:

> I want to learn Haskell but still have some problems on using recursion.
> On simple tasks I can make it work but for example the tower of Hanoi I
> cannot figure out how things are can be solved.
>
> Is there a book or tutorial with exercises so I can pratice it?
>
> Roelof
>
>
> ---
> Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
> http://www.avast.com
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150511/22c7c022/attachment-0001.html>

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

Message: 3
Date: Mon, 11 May 2015 16:38:11 +0000
From: Alexey Shmalko <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] help to learn recursion
Message-ID:
        <CAFC2PC6gHfxw+P3z9pVXGnNzfyGpLOJ=8+jy13lapeh5e4-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

You can try Haskell 99 problems [1]. At least first problems can help with
getting recursion (I haven't worked through later, so I don't know about
them).

[1]: https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems

On Mon, May 11, 2015, 18:44 Roelof Wobben <[email protected]> wrote:

> I want to learn Haskell but still have some problems on using recursion.
> On simple tasks I can make it work but for example the tower of Hanoi I
> cannot figure out how things are can be solved.
>
> Is there a book or tutorial with exercises so I can pratice it?
>
> Roelof
>
>
> ---
> Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
> http://www.avast.com
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150511/01c91a32/attachment-0001.html>

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

Message: 4
Date: Mon, 11 May 2015 22:11:04 -0400
From: Alex <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] AMQP and nested exception handlers
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Hi:

I am writing a small application which receives HTTP requests,
translates them to JSON, and queues the requests using RabbitMQ.

I am using exceptions to handle extreme cases, such as when a client's
HTTP request lacks a critical header:

lookupHeader :: RequestHeaders -> HeaderName -> Text
lookupHeader hs h = decodeUtf8 $ fromMaybe notFound
                                           (lookup h hs)
  where
    notFound = throw $ MissingHeader $ decodeUtf8 $ original h

The problem I am running in to is that the header isn't actually looked
up until I call the AMQP library's publishMsg function. If I purposely
do not supply a critical header, I get the following error printed to
the screen: 

ConnectionClosedException "ConnectionClosedException \"UNEXPECTED_FRAME
- expected content header for class 60, got non content header frame
instead\""

If I add the following line just above the publishMsg function (to
force evaluation), my exception handler is called successfully:

print $ encode req

As a result, I suspect that this is due to the fact that the "throw
MissingHeader" is getting captured by the AMQP library. What's the best
way to deal with this situation?

-- 
Alex


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

Message: 5
Date: Tue, 12 May 2015 09:17:16 +0530
From: Dananji Liyanage <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Reading, Processing, and Writing I/O
Message-ID:
        <CAAPsY8xuWp7Kpy0y1XEBadQpgJ03YKpBPbN68AJa2w=jv3i...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi All,

As a newcomer to Haskell, I'm following a tutorial to learn I/O in Haskell.

As an exercise I'm writing a small code to read from an input text file and
process it and then write it back to an output file.

The problem is that, it doesn't write to the output file after the input is
being processed.

Here's my code:

    module Main where

    import System.IO

    main = do
     input <- readFile "input.txt"
     let reversedInput = reverseInput (convert input)
     writeFile "reversed.txt" (reversedInput)

     -- These two lines are not printed on the shell
     putStrLn (show reversedInput)
     putStrLn "Writing to file...."

    -- Reversing the input
    reverseInput input = (last input) : reverseInput (init input)
    -- Convert from String IO -> String
    convert x = show (x)


-- 
Regards,
Dananji Liyanage
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150512/b1c3792a/attachment-0001.html>

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

Message: 6
Date: Tue, 12 May 2015 12:12:35 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading, Processing, and Writing I/O
Message-ID:
        <CAPY+ZdTCXG=kfSMEB8AfDKM6J+hnf6X0Ev3jUgm_d=k6c8f...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Tue, May 12, 2015 at 10:47 AM, Dananji Liyanage <[email protected]>
wrote:

reverseInput input = (last input) : reverseInput (init input)


This won't terminate. That's the bug.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150512/969746cd/attachment-0001.html>

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

Message: 7
Date: Tue, 12 May 2015 08:15:28 +0300
From: Kostiantyn Rybnikov <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] AMQP and nested exception handlers
Message-ID:
        <CAAbahfTSO_rO=s==cmgkocolap7mbzu5wxkmt+g8vekfqve...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi.

I would suggest to separate data-extraction from request stage and
data-sending one. Create a data-structure that will represent a thing you
will want to send into RabbitMQ, and build it before you send anything.
Then catch exceptions in IO-based layer to handle exception case.

This way you won't need any evaluation tricks and will get all exceptions
during that phase.

Cheers.
 12 ????. 2015 05:11 "Alex" <[email protected]> ????:

> Hi:
>
> I am writing a small application which receives HTTP requests,
> translates them to JSON, and queues the requests using RabbitMQ.
>
> I am using exceptions to handle extreme cases, such as when a client's
> HTTP request lacks a critical header:
>
> lookupHeader :: RequestHeaders -> HeaderName -> Text
> lookupHeader hs h = decodeUtf8 $ fromMaybe notFound
>                                            (lookup h hs)
>   where
>     notFound = throw $ MissingHeader $ decodeUtf8 $ original h
>
> The problem I am running in to is that the header isn't actually looked
> up until I call the AMQP library's publishMsg function. If I purposely
> do not supply a critical header, I get the following error printed to
> the screen:
>
> ConnectionClosedException "ConnectionClosedException \"UNEXPECTED_FRAME
> - expected content header for class 60, got non content header frame
> instead\""
>
> If I add the following line just above the publishMsg function (to
> force evaluation), my exception handler is called successfully:
>
> print $ encode req
>
> As a result, I suspect that this is due to the fact that the "throw
> MissingHeader" is getting captured by the AMQP library. What's the best
> way to deal with this situation?
>
> --
> Alex
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150512/8b199368/attachment.html>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 83, Issue 14
*****************************************

Reply via email to