3

How can I get the original F# code inside a quotation?

I know that in C# Expression.ToString() gives a reasonable string but it's not 100% and doesn't work in F#.

alakfq
  • 135
  • 8
  • 2
    http://www.fssnip.net/7OG/title/Quotation-Printer – CaringDev Jun 10 '18 at 08:13
  • 1
    What is a reasonable string for you? There is the Patterns and DerivedPatterns namespace under `Fsharp.Qutations` with their help you can pattern match on the expression. Take a look at [the Quations doc](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/code-quotations). – s952163 Jun 10 '18 at 08:13
  • 1
    I'm ultimately looking for something will give me the exact input between <@ @> – alakfq Jun 10 '18 at 10:11
  • I think the quotation printer quoted above is close, it uses non-light syntax though. I'm no quotation wizard, so not sure if this is possible (e.g. using reflection) or not. – s952163 Jun 10 '18 at 23:29

1 Answers1

1

I found the library Swensen.Unquote to give satisfactory results.

alakfq
  • 135
  • 8