anchor.diff:      else
           ctx.Writer.WriteLine("exception {0}", QuoteIdentifierIfNeeded exn.LogicalName)
   
  -and internal writeDelegateType ctx (del: FSharpEntity) =
  -    match del.Namespace with
  -    | Some ns -> ctx.Writer.WriteLine("namespace {0}", ns)
  -    | None -> ctx.Writer.WriteLine("module {0}", del.AccessPath)
  -    ctx.Writer.WriteLine("")
  +and internal writeDelegateType isNestedEntity ctx (del: FSharpEntity) =
  +    if not isNestedEntity then
  +        match del.Namespace with
  +        | Some ns -> ctx.Writer.WriteLine("namespace {0}", ns)
  +        | None -> ctx.Writer.WriteLine("module {0}", del.AccessPath)
  +        ctx.Writer.WriteLine("")
       writeDocs ctx del.XmlDoc
   
       let argsPart =
  
positive.code:             else moduleName
          else moduleName
  
      match modul.Namespace with
      | Some namespacePrefix -> 
          let moduleNameOnly =
              let prefixLength = namespacePrefix.Length + 1
              if prefixLength >= fullModuleNameWithoutModule.Length
              then fullModuleNameWithoutModule
              else fullModuleNameWithoutModule.Remove(0, prefixLength)
  
          namespacePrefix + "." + (QuoteIdentifierIfNeeded moduleNameOnly)
      | None -> QuoteIdentifierIfNeeded fullModuleNameWithoutModule
  
  let rec internal writeModule isTopLevel ctx (modul: FSharpEntity) =
      Debug.Assert(modul.IsFSharpModule, "The entity should be a valid F# module.")
  
negative.code:         | Entity(entity, _, _) ->
              match entity with
              | FSharpModule -> writeModule true ctx entity
              | AbbreviatedType abbreviatedType -> writeTypeAbbrev false ctx entity abbreviatedType
              | FSharpException -> writeFSharpExceptionType false ctx entity
              | Delegate when entity.IsFSharp -> writeDelegateType false ctx entity
              | _ -> writeType false ctx entity
              |> Some
          | MemberFunctionOrValue mem ->
              writeSymbol mem.LogicalEnclosingEntity
  