           callback result.slice(0,-1).map (line)->
             line.replace /\0/g,'\n'
     if text?
+      debug "sending stdin text to #{modPath}"
       process.process.stdin.write "#{text}\x04\n"
 
   runModiCmd: ({dir,options,command,text,uri,args,callback}) =>
+    debug "Trying to run ghc-modi in #{dir.getPath()}"
     process=@spawnProcess(dir,options)
     unless process
+      debug "Failed. Falling back to ghc-mod"
       return @runModCmd {options,command,text,uri,args,callback}
     parseData = (data)->
+      debug "Got response from ghc-modi:\n#{data}"
       lines = "#{data}".split("\n")
       result = lines[lines.length-2]
       unless result.match(/^OK/)

      stderr: (data) ->
        err=err.concat(data.split('\n'))
      exit: (code) ->
        if code!=0
          atom.notifications.addError "Haskell-ghc-mod: #{modPath}
              #{args.join ' '} failed with error code #{code}",

      cmd = [command].concat args
    if text?
      cmd = ['--file-map',uri].concat cmd
    debug "running #{modPath} #{cmd} with
          #{"options.#{k} = #{v}" for k,v of options}"
    process=new BufferedProcess
      command: modPath
      args: cmd
