Questions tagged [quotations]

Code quotations, a language feature that enables you to generate and work with F# code expressions programmatically. This feature lets you generate an abstract syntax tree that represents F# code.

Code quotations, a language feature that enables you to generate and work with F# code expressions programmatically. This feature lets you generate an abstract syntax tree that represents F# code.

For more information about F# quotations, please visit its MSDN page.

190 questions
5
votes
2 answers

F# quotations object graph

In C# I could create a string representation of an object graph fairly easily with expression trees. public static string GetGraph(TModel model, Expression> action) where TModel : class { var method =…
justin
  • 453
  • 1
  • 4
  • 13
5
votes
1 answer

Does anybody know the reason why QuotationEvaluator is so slow?

It's common knowledge in the F# community that the PowerPack's quotation compiling facility produces very slow code, so slow in fact that it performs even worse than naive interpretation. I've been looking into the reasons for this, but I haven't…
eirik
  • 608
  • 3
  • 11
5
votes
3 answers

Is there any built-in function for human-readable F# quotations?

When quoting <@ 1 + 1 @> I want "1 + 1" instead of "Call (None, Int32 op_Addition[Int32,Int32,Int32](Int32, Int32), [Value (1), Value (1)])"
dotneter
  • 1,689
  • 2
  • 15
  • 24
4
votes
5 answers

how to print \" in C++

I need to print a string that says exactly: std::string("-I\"/path/to/dir\" "); Basically, I need to do this because I am using C++ code to generate C++ code. I want to write the above string via an ofstream, so something like ofstream fout; fout…
user788171
  • 16,753
  • 40
  • 98
  • 125
4
votes
1 answer

How to call a function from the quotation of a invoke in type provider?

I have a type provider which gives me the error "Type mismatch when splicing expression into quotation literal". I extracted the code below in order to reproduce the issue in a smaller context. let f (s : string) : string = s //some dummy…
vidi
  • 2,056
  • 16
  • 34
4
votes
2 answers

Different Expressions being generated for "roughly" the same code quotation

given the following type type Foo = { foo: string; bar: int };; and the following code quotation <@fun v x -> { x with foo = v; bar = 99 } @>;; this will result in val it : Quotations.Expr<(string -> Foo -> Foo)> = Lambda (v, Lambda (x,…
robkuz
  • 9,488
  • 5
  • 29
  • 50
4
votes
1 answer

F# Quotation Generating very strange compile error

I am trying to work out why the following line: let emailQuotation: Expr string> = <@ fun (v: LoginView) -> v.Email.Text @> is failing with a compile error, saying "Lookup of object on indeterminate type...". The property…
Rob Lyndon
  • 12,089
  • 5
  • 49
  • 74
4
votes
1 answer

Can I get an identity of an F# quotation?

F# quotation is a wonderful feature, it allows us to treat F# expression as normal F# value. In my context, I use F# quotation to code Gpu kernel, and compile it into Gpu bitcode module. There is one problem. I don't want to compile Gpu kernel each…
Xiang Zhang
  • 2,831
  • 20
  • 40
4
votes
2 answers

Embed a variable inside an F# quotation

I'm writing an F# dsl for SQL (http://github.com/kolosy/furious). A select statement would look like this: type person = { personId: string firstname: string lastname: string homeAddress: address workAddress: address …
kolosy
  • 3,029
  • 3
  • 29
  • 48
4
votes
1 answer

Calling the base class method from Code Quotations

Let's say I have two simple classes : type BaseClass() = abstract member PreStart : unit -> unit default x.PreStart() = printfn "Base class PreStart method" type DerivedClass() as this = inherit BaseClass() override…
Tomasz Jaskuλa
  • 15,723
  • 5
  • 46
  • 73
4
votes
1 answer

F# argument checking

F# has some nice succint argument checking functions that can be used like this: let foo (bar : string) : string = if bar = null then nullArg "bar" ... I prefer a more prescriptive expression, however, a la Code Contracts: let foo…
Bent Rasmussen
  • 5,538
  • 9
  • 44
  • 63
4
votes
1 answer

F# quotation evaluation issue

I'm getting an issue with the F# powerpack quotation evaluation. open Microsoft.FSharp.Linq.QuotationEvaluation let print x = System.Console.WriteLine(sprintf "%A" x) type record = { x:int; y:int } let val1 = { x = 1; y = 1; } let val2 = { x = 1;…
justin
  • 453
  • 1
  • 4
  • 13
4
votes
1 answer

Regex to catch section between 2 quotations

I can't seem to get my regex right when trying to catch the phrase in between the quotations. E.g. in bold (NOTE: that the input is has strings before and after): "I can quite understand your thinking so." I said. "Of course, in your position of…
alvas
  • 115,346
  • 109
  • 446
  • 738
4
votes
1 answer

How to allow embedding not only values but arbitrary haskell expressions in antiquotes

Recently, I have learned how to implement quasiquoters with antiquote capabilities, like printfQ in the following piece of code: main = do let itemName = "apple" price = 1.29 [printfQ| The price of #{itemName} is #{price}. |] The…
nushio
  • 753
  • 3
  • 12
4
votes
1 answer

Quotations and pattern matching in F#

In a new console application, just pasting the following code leads to the exception "The parameter is not a recognized method name". Does the following code work on your installation? Joker: Do you know any reason why it would not work on…
nicolas
  • 9,549
  • 3
  • 39
  • 83
1 2
3
12 13