I was trying to run the following FParsec
code, until by some reason it stopped working:
The error I am getting is
"The value is not a function and cannot be applied."
If I comment out the last line of code (test ns ".."
) it will not yield an error, though. Any thoughts on how to solve this?
The source code in text form is the following:
open System
open FParsec
let test p str =
match run p str with
| Success(result, _, _) -> printfn "Success: %A" result
| Failure(errorMsg, _, _) -> printfn "Failure: %s" errorMsg
type Namespace = { Name : string; Classes : string list; }
let classes : Parser<string list, unit> =
many (spaces >>. many1Satisfy isLetter .>> spaces)
let ns =
pipe2
(spaces >>. skipString "namespace" >>. spaces >>. many1Satisfy isLetter)
(spaces >>. skipString "{" >>. classes .>> skipString "}")
(fun name classes -> { Name = name; Classes = classes } )
test ns "namespace abc { def ghi }"
Noone could have guessed the answer here. The problem lied with other thing that I had decided to exclude from the post: the very header of my file:
#if INTERACTIVE
#r @"C:\Users\xyz\Desktop\fparsec-main-default\Build\VS10\bin\Debug\FParsecCS.dll";
#r @"C:\Users\xyz\Desktop\fparsec-main-default\Build\VS10\bin\Debug\FParsec.dll";
#endif
Replacing the ;
by ;;
will make all errors disappear:
#if INTERACTIVE
#r @"C:\Users\xyz\Desktop\fparsec-main-default\Build\VS10\bin\Debug\FParsecCS.dll";;
#r @"C:\Users\xyz\Desktop\fparsec-main-default\Build\VS10\bin\Debug\FParsec.dll";;
#endif