2016-11-15 72 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解釋了爲什麼你看到的錯誤是它是什麼。