     @subscriptions = new CompositeDisposable
     @process=null
     @numInstances=0
+    @editorMap = new WeakMap
 
     atom.views.addViewProvider HaskellGhcModMessage, (message)->
       el=new HaskellGhcModMessageElement

  process: null
  subscriptions: null
  numInstances: 0

  config:
    checkOnSave:

      el

    @subscriptions.add atom.commands.add 'atom-text-editor',
      'haskell-ghc-mod:type': ({target}) =>
        @editorMap.get(target.getModel())?.getType()
      'haskell-ghc-mod:info': ({target}) =>
        @editorMap.get(target.getModel())?.getInfo()
      'haskell-ghc-mod:insert-type': ({target}) =>
        @editorMap.get(target.getModel())?.insertType()
      'haskell-ghc-mod:check': ({target}) =>
        @editorMap.get(target.getModel())?.doCheck()

    @subscriptions.add atom.workspace.observeTextEditors (editor) =>
      return unless editor.getGrammar().scopeName=="source.haskell"
      @numInstances += 1
      @process = new GhcModiProcess unless @process
      @editorMap.set(editor,new EditorController(@process,editor))
      editor.onDidDestroy =>
        @editorMap.get(editor)?.destroy()
        @editorMap.delete(editor)
        @numInstances -= 1
        if @numInstances==0
          @process?.destroy()
