
import Text.ParserCombinators.Parsec csvFile = endBy line eol line = sepBy cell (char ',') cell = many (noneOf ",\n") eol = char '\n' parseCSV :: String -> Either ParseError [[String]] parseCSV input = parse csvFile "(unknown)" input *showing error: <interactive>:1:32: Not in scope: `main' *

On Friday 14 October 2011, 21:59:22, kolli kolli wrote:
import Text.ParserCombinators.Parsec
csvFile = endBy line eol line = sepBy cell (char ',') cell = many (noneOf ",\n") eol = char '\n'
parseCSV :: String -> Either ParseError [[String]] parseCSV input = parse csvFile "(unknown)" input
*showing error: <interactive>:1:32: Not in scope: `main' *
If you don't have a module declaration in your file, it is assumed to be module Main (main) where thus, if there's no main function, compilation fails. Include a module declaration in your file, module Whatever (parseCSV, csvFile, line, cell, eol) where (the export list is optional, if you omit it, all top-level declarations are exported).

By the way, if you need a CSV parser, there are several already on Hackage: 'csv' [1] is the simplest; for more sophisticated uses there are also bytestring-csv [2] and csv-enumerator [3]. But perhaps you are just writing a CSV parser in order to learn Parsec; in which case, by all means carry on! -Brent [1] http://hackage.haskell.org/package/csv [2] http://hackage.haskell.org/package/bytestring-csv [3] http://hackage.haskell.org/package/csv-enumerator On Fri, Oct 14, 2011 at 01:59:22PM -0600, kolli kolli wrote:
import Text.ParserCombinators.Parsec
csvFile = endBy line eol line = sepBy cell (char ',') cell = many (noneOf ",\n") eol = char '\n'
parseCSV :: String -> Either ParseError [[String]] parseCSV input = parse csvFile "(unknown)" input
*showing error: <interactive>:1:32: Not in scope: `main' *
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

You need a main function, like:
main = do
x <- getContents
putStrLn $ parseCSV x
(This would read a string from stdin and pass it to parseCSV; then it would
print the result to stdout.)
L.
On Fri, Oct 14, 2011 at 8:59 PM, kolli kolli
import Text.ParserCombinators.Parsec
csvFile = endBy line eol line = sepBy cell (char ',') cell = many (noneOf ",\n") eol = char '\n'
parseCSV :: String -> Either ParseError [[String]] parseCSV input = parse csvFile "(unknown)" input
*showing error: <interactive>:1:32: Not in scope: `main' *
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (4)
-
Brent Yorgey
-
Daniel Fischer
-
kolli kolli
-
Lorenzo Bolla