commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

stack init --dep for dependency packages #1968

Open harendra-kumar opened 8 years ago

harendra-kumar commented 8 years ago

Sometimes a number of dependency packages are cloned into the tree of a project package. stack init currently does not distinguish between dependency packages and project packages. Which leads to problems especially when running stack ghci. stack ghci loads/interprets everything which takes time. In addition the packages might have conflicting compilation flags causing trouble like this:

* * * * * * * *
There are issues with this project which may prevent GHCi from working properly.

-XCPP will be used, but it can cause issues with multiline strings.
See https://downloads.haskell.org/~ghc/7.10.2/docs/html/users_guide/options-phases.html#cpp-string-gaps
It is specified for:
    snap-loader-dynamic:lib snap:lib
But not for: 
    servant-snap:lib servant-snap:exe:snap-greet hspec-snap:lib snap-loader-static:lib heist:lib heist-testsuite:exe:benchmark heist-testsuite:exe:testsuite io-streams-haproxy:lib io-streams:lib snap-core:lib snap-server:lib xmlhtml:lib xmlhtml-testsuite:exe:testsuite

-XTemplateHaskell will be used, but it may cause compilation issues due to different parsing of '$' when there's no space after it.
It is specified for:
    snap:lib
But not for: 
    servant-snap:lib servant-snap:exe:snap-greet hspec-snap:lib snap-loader-dynamic:lib snap-loader-static:lib heist:lib heist-testsuite:exe:benchmark heist-testsuite:exe:testsuite io-streams-haproxy:lib io-streams:lib snap-core:lib snap-server:lib xmlhtml:lib xmlhtml-testsuite:exe:testsuite

-XOverloadedStrings will be used, but it can cause type ambiguity in code not usually compiled with it.
It is specified for:
    snap:lib heist:lib heist-testsuite:exe:benchmark heist-testsuite:exe:testsuite xmlhtml:lib
But not for: 
    servant-snap:lib servant-snap:exe:snap-greet hspec-snap:lib snap-loader-dynamic:lib snap-loader-static:lib io-streams-haproxy:lib io-streams:lib snap-core:lib snap-server:lib xmlhtml-testsuite:exe:testsuite

-XTypeFamilies will be used, but it implies -XMonoLocalBinds, and so can cause type errors in code which expects generalized local bindings.
It is specified for:
    snap:lib
But not for: 
    servant-snap:lib servant-snap:exe:snap-greet hspec-snap:lib snap-loader-dynamic:lib snap-loader-static:lib heist:lib heist-testsuite:exe:benchmark heist-testsuite:exe:testsuite io-streams-haproxy:lib io-streams:lib snap-core:lib snap-server:lib xmlhtml:lib xmlhtml-testsuite:exe:testsuite

To resolve, remove the flag(s) from the cabal file(s) and instead put them at the top of the haskell files.

It isn't yet possible to load multiple packages into GHCi in all cases - see
https://ghc.haskell.org/trac/ghc/ticket/10827
* * * * * * * *

We could have a stack init --dep DIR option to specify which of the directories contain dependency packages so that we can mark them with extra-dep: true to avoid these problems. This option can be specified multiple times to specify multiple dirs.

A config generated with this option (e.g. stack init --dep deps) should look like this:

packages:
- '.'
- location: deps
  subdirs:
  - snap/deps/heist/
  - snap/deps/heist/test/
  - hspec-snap/
  - snap/deps/io-streams/
  - snap/deps/io-streams-haproxy/
  - snap/
  - snap/deps/snap-core/
  - snap-loader-dynamic/
  - snap-loader-static/
  - snap/deps/snap-server/
  - snap/deps/xmlhtml/
  - snap/deps/xmlhtml/test/
  extra-dep: true
mgsloan commented 8 years ago

Sounds good to me!