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:  ghc-6.10.3 IOException? (Daniel Fischer)
   2. Re:  timer_create: Invalid argument (Brandon S. Allbery KF8NH)
   3. Re:  ghc-6.10.3 IOException? (Erik de Castro Lopo)
   4. Re:  ghc-6.10.3 IOException? (Daniel Fischer)
   5.  Re: Strange errors in network (Maciej Piechotka)
   6.  ghci reports "The last statement in a 'do'       construct must be
      an expression" error (Nico Rolle)
   7. Re:  ghci reports "The last statement in a 'do'   construct
      must be an expression" error (Daniel Fischer)
   8.  question on layout (George Huber)
   9. Re:  question on layout (Daniel Fischer)


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

Message: 1
Date: Sun, 14 Jun 2009 14:27:32 +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 06:33:07 schrieb Erik de Castro Lopo:
> 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

Ah, I didn't follow the link yesterday, that code is from 2007.
With ghc-6.10, Control.Exception has been revamped, Exception is no longer a 
datatype but 
a type class.
Before 6.10, IOException was a constructor of Exception.

Simple solution:
import Control.OldException instead of Control.Exception

Harder long-time solution: 
rewrite the code to work with the new system.

I would first use the simple solution and then see whether it's worth the 
rewrite.

Cheers,
Daniel


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

Message: 2
Date: Sun, 14 Jun 2009 17:23:20 -0400
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] timer_create: Invalid argument
To: Thomas Friedrich <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Jun 8, 2009, at 10:35 , Thomas Friedrich wrote:
> However, when I run the program on a different computer, I get the  
> following:
>
> ~ $ scp count count.hs thom...@...:~
> tho...@...'s password:
> count                100%  492KB 492.2KB/s   00:00    
> count.hs             100%  125     0.1KB/s   00:00   ~ $ ssh  
> tho...@...
> [tho...@... ~] $ ./count count.hs
> count: timer_create: Invalid argument

Yep. This is due to differences between the installed glibc on the two  
systems; the Haskell runtime uses the appropriate timer_create code  
(necessary for threading) for the system it was built for, on other  
systems you can get the above error.  I see this a lot with local  
supported ghc builds, especially when trying to bootstrap from an  
existing binary.

All you can realistically do is relink the program on each system,  
which must have the appropriate compatible ghc runtime installed  
already.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20090614/2e183c7b/PGP-0001.bin

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

Message: 3
Date: Mon, 15 Jun 2009 08:29:27 +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:

> Simple solution:
> import Control.OldException instead of Control.Exception

I actually already had that working :-).
 
> Harder long-time solution: 
> rewrite the code to work with the new system.

This is what I'd like to do. Is there a guide or howto for converting
from OldException to Exception?

> then see whether it's worth the rewrite.

As a learning exercise I thin it is :-).

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


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

Message: 4
Date: Mon, 15 Jun 2009 01:19:57 +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 Montag 15 Juni 2009 00:29:27 schrieb Erik de Castro Lopo:
> Daniel Fischer wrote:
> > Simple solution:
> > import Control.OldException instead of Control.Exception
>
> I actually already had that working :-).

D'oh

>
> > Harder long-time solution:
> > rewrite the code to work with the new system.
>
> This is what I'd like to do. Is there a guide or howto for converting
> from OldException to Exception?

I don't know of one.

You could use the SomeException type and have

handler e = case fromException e of
               Just e' | isEOFError e' -> return ()
               _ -> print e

or you could only handle IOExceptions,

handler e
    | isEOFError e = return ()
    | otherwise = print e

either way, you must somehow determine which type of exception "throwTo 
mainTID" in spawn 
throws, in the first case its type would be (SomeException -> IO ()), in the 
second 
(IOException -> IO ()).
For the first case, it would probably better to have

act `catch` (throwTo mainTID . toException)

in spawn.

>
> > then see whether it's worth the rewrite.
>
> As a learning exercise I thin it is :-).

I agree.

>
> Erik



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

Message: 5
Date: Mon, 15 Jun 2009 12:21:24 +0200
From: Maciej Piechotka <[email protected]>
Subject: [Haskell-beginners] Re: Strange errors in network
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Sat, 2009-06-13 at 02:01 +0200, Maciej Piechotka wrote:
> 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). 

Apparently I needed to flush the stream despite having line buffering. 

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/20090615/7548a700/attachment-0001.bin

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

Message: 6
Date: Tue, 16 Jun 2009 22:35:17 +0200
From: Nico Rolle <[email protected]>
Subject: [Haskell-beginners] ghci reports "The last statement in a
        'do'    construct must be an expression" error
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hi

Heres my code snippet.
It reports that my error is in line 9 right after the main definition.
All functions that i call work under normal circumstances.
Thanks


module Benchmark
    where

import ReadCSV
import Operators
import Data.Time.Clock (diffUTCTime, getCurrentTime)

main = do
    xs <- readCSV "dataconvert/lineitem.tbl" '|'
    start <- getCurrentTime
    let pnp = projection [5] xs
    let snp = selection (\x -> (x!!0) > (Int 17000)) pnp
    end <- getCurrentTime
    putStrLn $ show (end `diffUTCTime` start)
    start2 <- getCurrentTime
    let pp = pProjection [5] xs
    let sp = pSelection (\x -> (x!!0) > (Int 17000)) pp
    end2 <- getCurrentTime
    putStrLn $ show (end2 `diffUTCTime` start2)
    return xs


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

Message: 7
Date: Tue, 16 Jun 2009 23:37:20 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] ghci reports "The last statement in a
        'do'    construct must be an expression" error
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

Am Dienstag 16 Juni 2009 22:35:17 schrieb Nico Rolle:
> Hi
>
> Heres my code snippet.
> It reports that my error is in line 9 right after the main definition.
> All functions that i call work under normal circumstances.
> Thanks

Must be the indentation, probably the xs is indented further than the following 
line 
(though that's not the case for the code copy-pasted from the mail to an 
editor).

But note that this will most likely print out 0 twice.
The let pnp = ... bindings don't cause any computation to occur.
To measure the time the computations take, you must force them to occur between 
the two 
calls to getCurrentTime.

>
>
> module Benchmark
>     where
>
> import ReadCSV
> import Operators
> import Data.Time.Clock (diffUTCTime, getCurrentTime)
>
> main = do
>     xs <- readCSV "dataconvert/lineitem.tbl" '|'
>     start <- getCurrentTime
>     let pnp = projection [5] xs
>     let snp = selection (\x -> (x!!0) > (Int 17000)) pnp
>     end <- getCurrentTime
>     putStrLn $ show (end `diffUTCTime` start)
>     start2 <- getCurrentTime
>     let pp = pProjection [5] xs
>     let sp = pSelection (\x -> (x!!0) > (Int 17000)) pp
>     end2 <- getCurrentTime
>     putStrLn $ show (end2 `diffUTCTime` start2)
>     return xs



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

Message: 8
Date: Tue, 16 Jun 2009 19:41:01 -0400
From: George Huber <[email protected]>
Subject: [Haskell-beginners] question on layout
To: [email protected].
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi,

This is more of a philosophical question then anything else. 

Recently I posted a question (see " exercise 3.10 in YAHT") and now 
Rolle is encountering what appears to be the same error (see "hci 
reports "The last statement in a 'do'    construct must be an 
expression" error").  In both cases the responses have been something on 
the order of "must be the indentation". 

So...my questions are:

(1) what was the driving force behind using white-space to denote code 
blocks?  From a beginners perspective (especially coming from a strong C 
/ C++ background) this seems to add to the learning curve for the 
language, and can add a good deal of frustration.

(2) I know using layout is optional -- we can curly braces and 
semicolons (not sure what this method is called correctly), but in the 
books and sources that I have looked at this seems to be mentioned in 
passing, so I'm guessing "good haskell format" is to use layout.  And if 
this is true, is there any reason for this?  better performance? easier 
parsing?

(3) Finally, is there a book or online reference that uses curly braces 
and semicolons from the start -- maybe introducing the concept of layout 
after all the language syntax is firmly grounded?


George.

PS -- For those of you that answered my first post, I sort-of solved my 
problem.  From your conviction that there was not an error in the 
function (even though this is where the compiler was claiming it to be), 
I moved stuff around in the source file while not touching the function 
itself and the error disappeared.  Not a satisfactory solution I know, 
but for now it will do till I get the syntax of Haskell down.  Thanks 
for everyone's help.

George



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

Message: 9
Date: Wed, 17 Jun 2009 03:39:56 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] question on layout
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

Am Mittwoch 17 Juni 2009 01:41:01 schrieb George Huber:
> Hi,
>
> This is more of a philosophical question then anything else.
>
> Recently I posted a question (see " exercise 3.10 in YAHT") and now
> Rolle is encountering what appears to be the same error (see "hci
> reports "The last statement in a 'do'    construct must be an
> expression" error").  In both cases the responses have been something on
> the order of "must be the indentation".
>
> So...my questions are:
>
> (1) what was the driving force behind using white-space to denote code
> blocks?  From a beginners perspective (especially coming from a strong C
> / C++ background) this seems to add to the learning curve for the
> language, and can add a good deal of frustration.

Readability.
Properly indented code is far easier to read, braces and semicolons are then 
only clutter.

>
> (2) I know using layout is optional -- we can curly braces and
> semicolons (not sure what this method is called correctly), but in the
> books and sources that I have looked at this seems to be mentioned in
> passing, so I'm guessing "good haskell format" is to use layout.  And if
> this is true, is there any reason for this?  better performance? easier
> parsing?

It's only easier to parse for humans, it's harder to write a parser for the 
layout rule.
But humans are considered more important.

>
> (3) Finally, is there a book or online reference that uses curly braces
> and semicolons from the start -- maybe introducing the concept of layout
> after all the language syntax is firmly grounded?
>

I know none.

>
> George.
>
> PS -- For those of you that answered my first post, I sort-of solved my
> problem.  From your conviction that there was not an error in the
> function (even though this is where the compiler was claiming it to be),
> I moved stuff around in the source file while not touching the function
> itself and the error disappeared.  Not a satisfactory solution I know,
> but for now it will do till I get the syntax of Haskell down.  Thanks
> for everyone's help.

Read http://haskell.org/onlinereport/lexemes.html#sect2.7
and http://haskell.org/onlinereport/syntax-iso.html#sect9.3
for an explanation of the layout rule.

>
> George



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

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


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

Reply via email to