• parse error on input when print specified lines of a file

    From Ben Bacarisse@21:1/5 to meInvent bbird on Wed Aug 24 10:07:56 2016
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to meInvent bbird on Tue Aug 23 11:00:06 2016
    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.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)