lukexi / stack-ide-sublime

An Sublime Text IDE for Haskell based on stack-ide
27 stars 5 forks source link

Multiple “Main” modules on executable targets #19

Closed yghor closed 9 years ago

yghor commented 9 years ago

When trying to use the IDE with a simple executable target and adding Main to other-modules as instructed, I get an error of multiple defined “Main” modules:

module ‘Main’ is defined in multiple files: /repo/Setup.hs
                                            /repo/source/Main.hs

Here is the target:

executable repo
  default-language:    Haskell2010
  hs-source-dirs:      source
  main-is:             Main.hs
  other-modules:       Main
  ghc-options:         -Wall
  build-depends:       base
                     , bytestring
                     , Cabal
                     , conduit
                     , conduit-extra
                     , http-conduit
                     , resourcet
                     , text

With: build-type: Simple. Here are the versions of tools in use:

tool commit
stack-ide-sublime 731ced2
stack-ide f78ff35abfbbc52e171ee109682c85baa9deb5f1
stack e22271f5ce9afa2cb5be3bad9cafa392c623f85c

Setup.hs:

import Distribution.Simple
main = defaultMain

source/Main.hs:

module Main where

import           Control.Monad.Trans.Resource (runResourceT)
import qualified Data.Conduit                 as C
import           Data.Conduit.Binary          (sinkFile)
import           Network.HTTP.Conduit

main :: IO ()
main = do
    request <- parseUrl "http://google.com"
    manager <- newManager tlsManagerSettings
    runResourceT $ do
        response <- http request manager
        responseBody response C.$$+- sinkFile "google.html"

Running stack build works normally from the command-line.

If I change the main module name to something other than Main, it stops building:

main-is:       Lard.hs
other-modules: Lard

setup-Simple-Cabal-1.22.4.0-x86_64-linux-ghc-7.10.2: can't find source for
Lard in source

Is this a stack-ide problem upstream, or is it the way things are handled here?

kerscher commented 9 years ago

I'm running on Ubuntu 14.04 LTS with stack.yaml pointing to lts-3.8. Sublime is on build 3095.

lukexi commented 9 years ago

Hi Yghor, this is a result of some upstream changes that I'm in the middle of adapting to (https://github.com/commercialhaskell/stack-ide/issues/81). There is a branch here https://github.com/lukexi/stack-ide-sublime/tree/windows-support that has the first part of the adaptation (it's a bit slow at the moment due to the naive way I implemented the first piece). You can give that a try and I'll let you know here as soon as I'm done as well!

kerscher commented 9 years ago

Thanks, switching to that branch does solve the problem :smiley: Maybe it's a good option to leave this open until it gets merged in master, so others know what to do meanwhile?

lukexi commented 9 years ago

Awesome!! I've merged the branch so I'll go ahead and close this!