FParsecを使用してコメントを空白として扱うパーサーを実装しています。簡単なパーサー変換が必要なようですが、それを実装する方法はまだわかりません。
これが私がタイプチェックしようとしているコードです-
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)
エラーは、両方の<|>
演算子の2番目の引数(over whitespaceText
)にあります。エラーは-
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'
をに変換する必要があるようParser<char list, 'a>
ですParser<string, 'a>
。または、スキップしているだけなので、両方をに変換できますParser<unit, 'a>
。しかし、そのコードの書き方がわかりません。単純なラムダ式ですか?
乾杯!