1

I'm currently making an application that analyses the typed AST of an FSharp program using FSharp Compiler Service.

I'm running into issues when it comes to identifying mutually recursive functions on module level declarations.

The TAST patterns allow me to determine if an expression is a recursive let with the pattern:

| BasicPatterns.LetRec(recursiveBindings, bodyExpr) ->

However, if I am at the module level, I instead get (in the case of 2 mutually recursive functions) 2 unrelated matches on the the matching rule for implementation file declarations:

| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(memberOrFuncOrVal, args, body) ->

I have been looking very thoroughly through the types of memberOrFuncOrVal, args and body and found not reference to the fact that the let binding is recursive, or any reference to the other mutually recursive function.

Is this information simply not available at the Typed AST level, or am I looking in the wrong place?

  • I don't have experience with the typed AST, but I'm nearly certain that mutually recursive functions are listed together in the untyped AST. I can dig up the details if it would help. – Brian Berns Mar 26 '21 at 13:58
  • Yes, you are right, they are listed together in the untyped AST, but I would like to be able to determine this in the typed AST, and not have to recurse over the full untyped AST beforehand. Thank you for the input though! :) – Jeppe Vinberg Mar 26 '21 at 14:28

0 Answers0