[Haskell-beginners] ghci reports "The last statement in a 'do' construct must be an expression" error

Daniel Fischer daniel.is.fischer at web.de
Tue Jun 16 17:37:20 EDT 2009


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



More information about the Beginners mailing list