       .map (s) =>
         @buildSymbolSuggestion(s, @prefix)
 
+  getModuleMatches: (prefix) =>
+    mod=""
+    @editor.backwardsScanInBufferRange /^import ([\w.]+)/, @lineRange,
+      ({match,stop}) ->
+        mod=match[1]
+        stop()
+    return [] unless mod?
+    @controller.backend.listImportedSymbols @editor.getBuffer(), [{name: mod}]
+      .then (symbols) =>
+        symbols
+          .filter (s) ->
+            s.name.startsWith(prefix)
+          .map (s) =>
+            @buildSymbolSuggestion(s,prefix)
+
   getSuggestions: =>
     if @isIn(@typeScope)
-      @getMatches(@prefix, 'type')
+      @genSpaceSearch()
+        .then (prefix) =>
+          @getMatches(prefix, true)
     else if @isIn(@moduleScope)
       @genSpaceSearch()
         .then(@getModule)
+    else if @isIn(@exportsScope)
+      @genSpaceSearch()
+        .then(@getModuleMatches)
     else if @isIn(@preprocessorScope)
       @genSpaceSearch()
         .then(@getPreprocessor)

    @prefix = @options.prefix
    @scopes = @options.scopeDescriptor.scopes
    @symbols = @controller.symbols

  genTypeSearch: =>
    unless @controller.backend

{Range} = require 'atom'
module.exports=
class SuggestionBuilder
  typeScope: ['meta.function.type-declaration.haskell']
  sourceScope: ['source.haskell']
  moduleScope: ['meta.import.haskell', 'support.other.module.haskell']
  preprocessorScope: ['meta.preprocessor.haskell']
  exportsScope: ['meta.import.haskell', 'meta.declaration.exports.haskell']
  #TODO: exports scope

  constructor: (@options,@info,@controller) ->
