3

I am using the parseFile function from Fantomas.FCS as follows:

open FSharp.Compiler.Text
open Fantomas.FCS.Parse
// ... 
let ast, errors = parseFile false (FSharp.Compiler.Text.SourceText.ofString "let mutable x = 3") []

However, the compiler says that

The type 'FSharp.Compiler.Text.ISourceText' is not compatible with the type 'FSharp.Compiler.Text.ISourceText (Fantomas.FCS, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null)'

I have located the file here, which seems to be in the nuget package FSharp.Compiler.Service. However, downloading the latest version of that does not resolve the conflict. I then looked at the version Fantomas.FCS (version 5.0.0-beta-002) is using. It seems that Fantomas is obtaining the FSharp.Compiler.Text namespace files from github: https://github.com/fsprojects/fantomas/blob/master/paket.dependencies. I have tried to use paket to download these files, using a similar setup as Fantomas, but had issues with transitive dependencies. The method also seems messy. Is there a way to resolve the type incompatibility?

  • 1
    I tried your code but couldn't reproduce the issue, this compiles fine for me – Maku Nov 27 '22 at 14:06
  • I assume you tried it with the same dependency setups. If not, perhaps the issue got fixed with new versions. Anyway, I ended up using FSharp.Formatting.CodeFormat (https://fsprojects.github.io/FSharp.Formatting/codeformat.html) to tokenize F# code. – cheetomasta420 Nov 29 '22 at 00:07
  • yeah I used version 5.0.0-beta-002 as you stated – Maku Nov 29 '22 at 07:20

0 Answers0