Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #459

Re: parse error on input when print specified lines of a file

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.haskell
Subject Re: parse error on input when print specified lines of a file
Date 2016-08-24 10:07 +0100
Organization A noiseless patient Spider
Message-ID <87wpj6pmab.fsf@bsb.me.uk> (permalink)
References <cc369812-eba8-4c76-86e0-3f06e1e91d59@googlegroups.com> <87d1kzst3t.fsf@bsb.me.uk> <ee88453c-d7f6-412e-8959-bd938587d8f8@googlegroups.com>

Show all headers | View raw


meInvent bbird <jobmattcon@gmail.com> writes:
>
> On Tuesday, August 23, 2016 at 6:00:07 PM UTC+8, Ben Bacarisse wrote:
>> meInvent bbird <jobmattcon@gmail.com> writes:
>> 
>> > parse error on input `\'
>> >
>> > import System.IO  
>> > import Control.Monad
>> >
>> > main = do
>> >   file <- readFile "hello.txt"
>> >   forM_ [5..7] (lines file) \i -> 
>> >       putStrLn i
>> 
>> Did you mean
>> 
>>   forM_ (lines file) (\i -> putStrLn i)
>> 
>> ?  The syntax error is that you need ()s round the lambda expression
>> here, but the extra list [5..7] is puzzling me.
>
> would like to choose specified lines to display

Then replace (lines file) with an expression that gives the lines you
want.  For example (take 2 (drop 4 (lines file)))  (which is neater
using $ but that's not the point).

-- 
Ben.

Back to comp.lang.haskell | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

parse error on input when print specified lines of a file meInvent bbird <jobmattcon@gmail.com> - 2016-08-23 01:52 -0700
  Re: parse error on input when print specified lines of a file Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-23 11:00 +0100
    Re: parse error on input when print specified lines of a file meInvent bbird <jobmattcon@gmail.com> - 2016-08-23 18:40 -0700
      Re: parse error on input when print specified lines of a file meInvent bbird <jobmattcon@gmail.com> - 2016-08-23 18:49 -0700
      Re: parse error on input when print specified lines of a file Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-24 10:07 +0100

csiph-web