stephan-tolksdorf / fparsec

A parser combinator library for F#
523 stars 45 forks source link

You must add a reference to assembly 'FParsecCS' #61

Closed no1melman closed 2 years ago

no1melman commented 4 years ago

I've just started out with FParsec, and I'm not super well versed in F#.

I found that doing

#r "./FParsec.dll"
#r "./FParsecCS.dll"

open FParsec

let asStr s = pstring s

let numberBetweenQuotes = 
  asStr "\"" >>. pfloat .>> asStr "\""

printfn "%A" (run numberBetweenQuotes "\"100,200.00\"") |> ignore

This throws an error:

error FS0074: The type referenced through 'FParsec.CharStream`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'FParsecCS'.

However, if you switch the order of the #r then it goes away:

#r "./FParsecCS.dll"
#r "./FParsec.dll"

Is this a known caveat - following the tutorial, it doesn't say anything about that. And it just so happens by chance that I tried it out.

Is this an fparsec thing or a f# script thing - or a combination of the both? Is it worth documenting?

njlr commented 2 years ago

Probably the easiest way to do this from .NET 5 onwards is using a Nuget reference:

#r "nuget: FParsec"
// #r "nuget: FParsec, 1.1.1" // Versioned

open FParsec

// ...
no1melman commented 2 years ago

Yeah for sure, this was definitely pre that. defo can close this in favour for that

abelbraaksma commented 2 years ago

Maybe a good idea to add this to the readme.md @stephan-tolksdorf?