Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created May 14, 2015 18:38
Show Gist options
  • Save SteveGilham/a5f0ec2c7de7764fcfb9 to your computer and use it in GitHub Desktop.
Save SteveGilham/a5f0ec2c7de7764fcfb9 to your computer and use it in GitHub Desktop.
Function serialization example
open System
open System.IO
open System.Runtime.Serialization.Formatters.Soap
open System.Text
let mhead(m : list<Object>) : list<Object> = [m.Head]
let addN n =
(fun x -> x + n)
let add2 = addN 2
let emitString x =
let sf = new SoapFormatter()
let sink = new MemoryStream()
sf.Serialize(sink, x)
printfn "%s" <| x.GetType().FullName
printfn "%s" <| Encoding.Default.GetString(sink.ToArray())
[ mhead :> obj; addN :> obj; add2 :> obj; emitString :> obj]
|> Seq.iter emitString
printfn "-------------------"
[ mhead :> obj; addN :> obj; add2 :> obj; emitString :> obj]
|> Seq.iter emitString;
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment