2016-11-15 73 views
1

所以我从FParsec示例运行下面的代码,但它似乎并不想运行。FParsec示例为什么不运行?

namespace Test 
open FParsec.CharParsers 
module Stuff = 
    let main = run pfloat "1.25E3" 
    let str s = pstring s 
    let floatBetweenBrackets = str "[" >>. pfloat .>> str "]" 

的问题是最后一行 - 我得到这个错误:

Error 1 Expecting a type supporting the operator '>>.' but given a function type. You may be missing an argument to a function. C:\Users\...\Documents\Visual Studio 2013\Projects\Solution2\ConsoleApplication1\load.fs 6 42 Formatting 

的代码是从这里:

http://www.quanttec.com/fparsec/tutorial.html#parsing-a-float-between-brackets 

如果它的事项,F#的版本,我运行是:

Microsoft (R) F# Interactive version 12.0.30110.0 
+2

我觉得'(>>。)'是在'FParsec.Primitives'模块中定义的,所以您需要打开代码进行编译。 – kvb

回答

4

>>.FParsec.Primitives中定义,所以你也需要打开它。或者,你可以打开FParsecsince

Opening the FParsec namespace also automatically opens the Primitives, CharParsers and Error modules.

This answer解释了为什么你看到的错误是它是什么。