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: 
      ctx.Writer.Unindent ctx.Indentation
  
  and internal writeTypeAbbrev ctx (abbreviatingType: FSharpEntity) (abbreviatedType: FSharpType) =
      match abbreviatingType.Namespace with
      | Some ns -> ctx.Writer.WriteLine("namespace {0}", ns)
      | None -> ctx.Writer.WriteLine("module {0}", abbreviatingType.AccessPath)
      ctx.Writer.WriteLine("")
  
      writeDocs ctx abbreviatingType.XmlDoc
      ctx.Writer.WriteLine("type {0} = {1}",
                           QuoteIdentifierIfNeeded abbreviatingType.LogicalName,
                           abbreviatedType.Format(ctx.DisplayContext))
  
  and internal writeFSharpExceptionType ctx (exn: FSharpEntity) =
      match exn.Namespace with
      | Some ns -> ctx.Writer.WriteLine("namespace {0}", ns)
      | None -> ctx.Writer.WriteLine("module {0}", exn.AccessPath)
      ctx.Writer.WriteLine("")
  
      writeDocs ctx exn.XmlDoc
  
  
negative.code:             else moduleName
          else moduleName
  
      let prefixToConsider =
          match modul.Namespace with
          | Some namespacePrefix -> namespacePrefix
          // TODO: it's not because there's no namespace that the module is not inside a module
          // Ex: module Microsoft.FSharp.Compiler.Range.Pos
          // -> Pos is in the Range module
          | None -> if modul.AccessPath = "global" then "" else modul.AccessPath
  
      let moduleNameOnly =
          let prefixLength = prefixToConsider.Length + 1
          if prefixLength >= fullModuleNameWithoutModule.Length || prefixToConsider = ""
          then fullModuleNameWithoutModule
          else fullModuleNameWithoutModule.Remove(0, prefixLength)
  
      if prefixToConsider = "" then
          QuoteIdentifierIfNeeded moduleNameOnly
      else
          prefixToConsider + "." + (QuoteIdentifierIfNeeded moduleNameOnly)
  
  let rec internal writeModule isTopLevel ctx (modul: FSharpEntity) =
      Debug.Assert(modul.IsFSharpModule, "The entity should be a valid F# module.")
  