anchor.diff:              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 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.")
  
positive.code:     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("")
      writeDocs ctx del.XmlDoc
  
      let argsPart =
  
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
  