I implement a parser that treats comments as spaces using FParsec. It seems like this requires a trivial parser transformation, but I don't know yet how to implement this.
Here's the code I'm trying to get to check the type -
let whitespaceTextChars = " \t\r\n" /// Read whitespace characters. let whitespaceText = many (anyOf whitespaceTextChars) /// Read a line comment. let lineComment = pchar lineCommentChar >>. restOfLine true /// Skip any white space characters. let skipWhitespace = skipMany (lineComment <|> whitespaceText) /// Skip at least one white space character. let skipWhitespace1 = skipMany1 (lineComment <|> whitespaceText)
Error in the second argument of the <|> operators (more than whitespaceText ). Errors -
Error 1 Type mismatch. Expecting a Parser<string,'a> but given a Parser<char list,'a> The type 'string' does not match the type 'char list' Error 2 Type mismatch. Expecting a Parser<string,'a> but given a Parser<char list,'a> The type 'string' does not match the type 'char list'
It seems I need to convert Parser<char list, 'a> to Parser<string, 'a> . Or, since I just skip them, I could convert them both to Parser<unit, 'a> . However, I do not know how to write this code. Is this a simple lambda expression?
Hurrah!
source share