anchor.diff:                          nameAttr.Value)
           |> Seq.distinct
   
  +    // In-place text replace
       let replaceText (name: string) (value: string) (template: XElement) =
           let textElems = 
               template.Descendants(textElemName)
  -            |> Seq.choose (fun e -> 
  +            |> Seq.where (fun e -> 
                               let nameAttr = e.Attribute(XName.Get "name")
  -                            if nameAttr = null || nameAttr.Value <> name then
  -                                None
  -                            else
  -                                Some e)
  -            |> Seq.toList |> List.toSeq
  +                            nameAttr <> null && nameAttr.Value = name)
  +            |> Seq.toList
           for e in textElems do
               e.ReplaceWith(XText(value))
  -        
  -        template        
  +
  +open Impl
   
   [<TypeProvider>]
   type public HtmlProvider(cfg:TypeProviderConfig) as this =
  
positive.code: open System.Xml
  open System.Xml.Linq
  
  module Impl =
      [<Literal>]
      let xmlns = "http://www.example.com/HtmlTypeProvider"
  
  
negative.code:     let htmlTy = ProvidedTypeDefinition(thisAssembly, rootNamespace, "Html", Some baseTy, IsErased = false)
      let buildType (assembly: ProvidedAssembly) typeName (args: obj[]) =
          let html = args.[0] :?> string
          let xelem = loadXml html
          let ty = ProvidedTypeDefinition(typeName, Some baseTy, IsErased = false)
          let templateField = ProvidedField("__template", typeof<string>)
          templateField.SetFieldAttributes FieldAttributes.InitOnly
          ty.AddMember templateField
          let texts = getTextSplices xelem |> Seq.distinct |> Seq.toList
          let fields = texts |> Seq.map (fun s -> ProvidedField(s, typeof<string>)) |> Seq.toList
          for f in fields do
              f.SetFieldAttributes FieldAttributes.InitOnly
          ty.AddMembers fields
          let ctorBody (args: Expr list) : Expr = 
              let this = args.[0]
              let setTemplate = Expr.FieldSet(this, templateField, Expr.Value html)
              let setFields = Seq.zip fields (Seq.skip 1 args) |> Seq.map (fun (f,a) -> Expr.FieldSet(this, f, a))
              Expr.Sequentials [yield setTemplate; yield! setFields]
          let ctorParams = texts |> Seq.map (fun s -> ProvidedParameter(s, typeof<string>)) |> Seq.toList
          ty.AddMember(ProvidedConstructor(ctorParams, InvokeCode = ctorBody))
          let render (this: Expr) : XElement Expr =
              let templateExpr = 
                  <@
                      let templateHtml: string = (%%Expr.FieldGet(this, templateField))
                      let template = loadXml templateHtml
                      Impl.replaceText (%%(Expr.Value fields.[0].Name)) (%%(Expr.FieldGet(this, fields.[0]))) template
                      template
                  @>
              templateExpr
          let methods = ProvidedMethod("Render", [], typeof<XElement>, InvokeCode = fun args -> render args.[0] :> _)
  