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:  exercise 3.10 in YAHT (Brent Yorgey)
   2.  Re: exercise 3.10 in YAHT (Maur??cio)
   3.  Testing unpure network code (Maciej Piechotka)
   4. Re:  Testing unpure network code (Isaac Dupree)
   5. Re:  Testing unpure network code (Maciej Piechotka)
   6. Re:  Testing unpure network code (Maciej Piechotka)
   7.  Strange errors in network (Maciej Piechotka)
   8.  ghc-6.10.3 IOException? (Erik de Castro Lopo)
   9. Re:  ghc-6.10.3 IOException? (Daniel Fischer)
  10. Re:  ghc-6.10.3 IOException? (Erik de Castro Lopo)


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

Message: 1
Date: Tue, 9 Jun 2009 01:17:49 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] exercise 3.10 in YAHT
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Tue, Jun 09, 2009 at 12:05:21AM -0400, George Huber wrote:
>
> loading the file that contains the above function into GHCi (version 6.8.3) 
> gives the following error "The last statement in a 'do' construct must be 
> an expression"
>

This error can also sometimes be triggered by indentation problems.
Check to make sure you are using only spaces and not tabs to
indent. (Tabs are interpreted as a certain number of spaces by ghc---I
forget how many---which may be different than the number of spaces
your editor is configured to show them as, which can lead to
indentation being screwy.  Good Haskell practice is to never use tabs;
in practice most editors have an option to turn tabs into spaces.)

Dunno if that's really your problem but it's worth a shot!

-Brent


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

Message: 2
Date: Tue, 09 Jun 2009 19:26:36 -0300
From: Maur??cio <[email protected]>
Subject: [Haskell-beginners] Re: exercise 3.10 in YAHT
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

> loading the file that contains the above function into GHCi (version 
> 6.8.3) gives the following error "The last statement in a 'do' construct 
> must be an expression"
> 
> being a beginner, I'm at a loss at the cause of the error and how to fix 
> it -- any suggestions?
> 
> thanks,
> george

No problem here too, ghc 6.8.2.

Maybe seeing how things are when layout style is not used
helps you see a possible layout problem. Maybe it doesn't,
and you can just forget the example below :)

module Main (main) where {
   getNums = putStrLn "Enter a number (zero to stop):" >> do {
     num <- readLn ;
     if num == 0 then return [] else
       do {rest <- getNums ; return (num:rest)}
   } ;

   main = getNums >>= putStrLn . show
}

Best,
MaurĂ­cio



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

Message: 3
Date: Thu, 11 Jun 2009 13:59:44 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Testing unpure network code
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hello. I have a problem with testing. I've wrote a client library for
NNTP protocol. However I don't know how to test it.

I though about spawning a thread for server inside a test but Haskell
(ghc and hugs?) uses green blocking threads so forkIO is not an option.
I cannot also use POSIX fork as in documentation it is stated that I
cannot use IO in argument. I'd not like to create separate process as
IPC is not something nice (and there is separation between two parts of
test). Testing on real server have also some disadvantages (on real one
it is not predictable and setting one just for tests...)

What is the correct solution?

PS. Please CC me as I'm not subscribe to the list. I will eventually use
Gmane but well. I'm in the process of writing NNTP client as no other
suited me ;)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090611/eb10d595/attachment-0001.bin

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

Message: 4
Date: Thu, 11 Jun 2009 09:59:09 -0400
From: Isaac Dupree <[email protected]>
Subject: Re: [Haskell-beginners] Testing unpure network code
To: Maciej Piechotka <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Maciej Piechotka wrote:
> Hello. I have a problem with testing. I've wrote a client library for
> NNTP protocol. However I don't know how to test it.
> 
> I though about spawning a thread for server inside a test but Haskell
> (ghc and hugs?) uses green blocking threads so forkIO is not an option.

GHC forkIO uses threads that can make blocking foreign calls in parallel 
(*not* blocking the whole process), at least if you compile with
ghc -threaded

-Isaac


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

Message: 5
Date: Fri, 12 Jun 2009 13:03:07 +0200
From: Maciej Piechotka <[email protected]>
Subject: Re: [Haskell-beginners] Testing unpure network code
To: Isaac Dupree <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Thu, 2009-06-11 at 09:59 -0400, Isaac Dupree wrote:
> Maciej Piechotka wrote:
> > Hello. I have a problem with testing. I've wrote a client library for
> > NNTP protocol. However I don't know how to test it.
> > 
> > I though about spawning a thread for server inside a test but Haskell
> > (ghc and hugs?) uses green blocking threads so forkIO is not an option.
> 
> GHC forkIO uses threads that can make blocking foreign calls in parallel 
> (*not* blocking the whole process), at least if you compile with
> ghc -threaded
> 
> -Isaac

Thank you. Is there any guide how to set up tests? I have sources in
src/ directory and tests in tests/.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090612/b3f905df/attachment-0001.bin

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

Message: 6
Date: Sat, 13 Jun 2009 01:40:58 +0200
From: Maciej Piechotka <[email protected]>
Subject: Re: [Haskell-beginners] Testing unpure network code
To: Isaac Dupree <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Fri, 2009-06-12 at 13:03 +0200, Maciej Piechotka wrote:
> On Thu, 2009-06-11 at 09:59 -0400, Isaac Dupree wrote:
> > Maciej Piechotka wrote:
> > > Hello. I have a problem with testing. I've wrote a client library for
> > > NNTP protocol. However I don't know how to test it.
> > > 
> > > I though about spawning a thread for server inside a test but Haskell
> > > (ghc and hugs?) uses green blocking threads so forkIO is not an option.
> > 
> > GHC forkIO uses threads that can make blocking foreign calls in parallel 
> > (*not* blocking the whole process), at least if you compile with
> > ghc -threaded
> > 
> > -Isaac
> 
> Thank you. Is there any guide how to set up tests? I have sources in
> src/ directory and tests in tests/.
> 
> Regards

Ok. I found out. For those who will search - -i option sets the search
path so runhaskell -isrc test/... will do.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090612/1353a156/attachment-0001.bin

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

Message: 7
Date: Sat, 13 Jun 2009 02:01:29 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Strange errors in network
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

I have problems with my nntp library (http://code.haskell.org/nntp/). If
I try to list command it seems to fail.

Test code:
> (c,p) <- connectToHost "news.example.com" Nothing
> forGroups c (System.IO.putStrLn . groupName)
*** Exception: <socket: 6>: Data.ByteString.hGetLine: end of file

Conncection by telnet (according to wireshark):
-> SYN
<- SYN, ACK
-> ACK
<- NNTP Helo Message
-> ACK

Connection by Haskell:
-> SYN
<- SYN ACK
-> ACK
<- NNTP Helo Message
-> ACK
<- FIN ACK (after 10 s)
-> ACK

If I try to run by hand the commands in ghci I get mixed results
(sometimes works sometimes it fails). 

What's wrong?
PS. example.com is an example, non-existing domain. It is specified by a
RFC to be an example domain.
PPS. As I'm not subscribe the list please CC me
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090612/eb862c19/attachment-0001.bin

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

Message: 8
Date: Sun, 14 Jun 2009 09:58:06 +1000
From: Erik de Castro Lopo <[email protected]>
Subject: [Haskell-beginners] ghc-6.10.3 IOException?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Hi all,

I have some code (basically from http://sequence.complete.org/node/257)
which  has:

    import Control.Exception (finally, catch, Exception (..), IOException)

...

    handler (IOException e)
        | isEOFError e = return ()

but gch-6.10.3 still says

    Not in scope: data constructor `IOException'

Someone smack me with the cluestick please :-).

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


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

Message: 9
Date: Sun, 14 Jun 2009 02:14:06 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] ghc-6.10.3 IOException?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

Am Sonntag 14 Juni 2009 01:58:06 schrieb Erik de Castro Lopo:
> Hi all,
>
> I have some code (basically from http://sequence.complete.org/node/257)
> which  has:
>
>     import Control.Exception (finally, catch, Exception (..), IOException)
>
> ...
>
>     handler (IOException e)
>
>         | isEOFError e = return ()
>
> but gch-6.10.3 still says
>
>     Not in scope: data constructor `IOException'
>
> Someone smack me with the cluestick please :-).
>

a) you only imported the type, not the data constructor(s)
b) confusingly, the constructor of IOException is IOError:

data IOException
 = IOError {
     ioe_handle   :: Maybe Handle,   -- the handle used by the action flagging 
                                     -- the error.
     ioe_type     :: IOErrorType,    -- what it was.
     ioe_location :: String,         -- location.
     ioe_description :: String,      -- error type specific information.
     ioe_filename :: Maybe FilePath  -- filename the error is related to.
   }
    deriving Typeable

instance Exception IOException



> Cheers,
> Erik



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

Message: 10
Date: Sun, 14 Jun 2009 14:33:07 +1000
From: Erik de Castro Lopo <[email protected]>
Subject: Re: [Haskell-beginners] ghc-6.10.3 IOException?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Daniel Fischer wrote:

> a) you only imported the type, not the data constructor(s)
> b) confusingly, the constructor of IOException is IOError:
> 
> data IOException
>  = IOError {
>      ioe_handle   :: Maybe Handle,   -- the handle used by the action 
> flagging 
>                                      -- the error.
>      ioe_type     :: IOErrorType,    -- what it was.
>      ioe_location :: String,         -- location.
>      ioe_description :: String,      -- error type specific information.
>      ioe_filename :: Maybe FilePath  -- filename the error is related to.
>    }
>     deriving Typeable
> 
> instance Exception IOException

Ok, I can see whats wrong, but I still have no idea how to fix it.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 12, Issue 5
****************************************

Reply via email to