代写 html XML C# F# CCS 335 2019 Page 1 of 2 A#6C v1 F# Lambdas as Code Quotations

CCS 335 2019 Page 1 of 2 A#6C v1 F# Lambdas as Code Quotations
XML Serialisation & Deserialisation, Postfix
A#6C is a bonus++ assignment, conceptually similar to the A#6B bonus.
Highlights summary:
o We use F# instead of C#
o We still use only simple lambdas, with no free variables, just int variables and literals, and the four basic arithmetic operations (+, -, *, /)
o Our lambdas are given as untyped code quotations – F# type Quotations.Expr
o On stdin, we receive one XML serialisation of an untyped code quoted lambda
o On stdout, we must print one single line with its postfix equivalent (we do NOT require any evaluation)
o Our lambdas have been serialised to XML by FsPickler – so should also be deserialised by FsPickler
o We use the adapted version called FsPicklerUoA.dll (see Samples folder), which seems to work well on our machines and on automarker’s mono
Background
In F#, almost anything is an expression and can be given via a code quotation. Thus, F# code quotations are much more general and powerful than C# expression trees.
FsPickler is probably the best choice for serialising and deserialising F# objects, including code quotations. It is used by large distributed actor and cloud frameworks, such as MBrace.
Readings (non exhaustive) For code quotations:
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/code- quotations/
For FsPickler: https://mbraceproject.github.io/FsPickler/tutorial.html

CCS 335 2019 Page 2 of 2 A#6C v1 The A#6C samples folder contains:
o A sample F# source using our adapted FsPicklerUoA.dll, with its associated batch script.
The given sample serialises and then deserialises a list of tuples, NOT code quotations (that will be our task).
o Side bar: sample original lambda, as an untyped code quotation – NOT actually given in the samples folder, here just for illustration:
o Its XML serialisation (see the actual text in the samples folder):
o Its expected postfix notation (also in the folder):
Various lambdas that could appear, serialised, as automarker test cases:


<@@ fun () -> … @@>
<@@ fun x -> … @@>
<@@ fun x y -> … @@>
<@@ fun x -> fun y -> … @@> <@@ fun (x, y) -> … @@> <@@ fun x y z w -> … @@>
Good luck!
<@@ fun x -> (x + 34) * (x + 77) @@>
x 34 + x 77 + *