anchor.diff:          box (fun (a: obj[]) ->
               Set.ofArray(Array.map decEl a))
   
  -    let Record decEl = Encode.Record decEl
  +    let Record (fields: (string * (obj -> obj) * OptionalFieldKind)[]) =
  +        box (fun (x: obj) ->
  +            let o = New []
  +            fields |> Array.iter (fun (name, enc, kind) ->
  +                match kind with
  +                | OptionalFieldKind.NotOption ->
  +                    o?(name) <- enc x?(name)
  +                | OptionalFieldKind.NormalOption ->
  +                    o?(name) <-
  +                        if JS.HasOwnProperty x name
  +                        then Some x?(name)
  +                        else None
  +                | OptionalFieldKind.MarkedOption ->
  +                    if JS.HasOwnProperty x name then
  +                        o?(name) <- x?(name)
  +                | _ -> failwith "Invalid field option kind")
  +            o)
   
       let Array decEl = Encode.Array decEl
   
  
positive.code:             l |> List.iter (fun x -> a.JS.Push (encEl x) |> ignore)
              a)
  
      let Record (fields: (string * (obj -> obj))[]) =
          box (fun (x: obj) ->
              let o = New []
              fields |> Array.iter (fun (name, enc) ->
                  o?(name) <- enc x?(name))
              o)
  
      let Array (encEl: 'T -> obj) =
  
negative.code: open WebSharper.JavaScript
  open WebSharper.Core.Attributes
  
  type private OptionalFieldKind =
      | NotOption = 0     // The field doesn't have type option<'T>
      | NormalOption = 1  // The field has type option<'T>
      | MarkedOption = 2  // The field has type option<'T> and is marked [<OptionalField>]
  
  [<JavaScript>]
  module private Encode =
  
  