commercialhaskell / commercialhaskell/stack
Supporting using the same .stack-work directory for multiple projects
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
Tracking the conversation in https://github.com/commercialhaskell/stack/issues/1178, it seems that it's not supported to have one shared .stack-work directory for multiple projects, although it would be nice in order to cache work in a CI system. I understand that the _path_ to the workdir must be a relative path to a child directory, but I was curious if the actual directories could be the same, and the per-project workdirs could simply be symlinks to the one shared workdir. However, I run into an interesting error (sanitized):
```
[41 of 44] Compiling MainProj.A
/home/kevin/main-proj/src/MainProj/A.hs:190:38: error:
• Couldn't match type ‘somelib-0.1.0.0:SomeLib.LibMod.SomeType’
with ‘SomeType’
NB: ‘SomeType‘ is defined at
src/SomeLib/LibMod.chs:(24,1)-(33,29)
‘somelib-0.1.0.0:SomeLib.LibMod.SomeType’
is defined in ‘SomeLib.LibMod’ in package ‘somelib-0.1.0.0’
arising from a functional dependency between:
constraint ‘BB.HasSomeType (Foo f) SomeType’
arising from a use of ‘BB.someType’
instance ‘BB.HasSomeType
(Foo f) somelib-0.1.0.0:SomeLib.LibMod.SomeType’
at
• In the second argument of ‘(^.)’, namely ‘BB.someType’
In the expression: bar ^. BB.someType
In the expression:
case bar ^. BB.someType of
SomeCons1 -> f True
SomeCons2 -> f False
_ -> return Nothing
|
190 | getThing bar = case bar ^. BB.someType of
| ^^^^^^^^^^^
```
(here `BB` is an alias for another module in `SomeLib`).
This is the sort of error that I was expecting to get, if there would be any errors. However, this is surprisingly the first (and only) error I get in the first 40 modules for this project, and many of the earlier modules do in fact use the library. However, it's the only one in the first 40 that seems to use a typeclass that's exported by the library, and I wonder if there are any workarounds I could apply to either code base in order to support using the same workdir for both projects.
### Stack version
```
$ stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
```
### Method of installation
`stack-static` AUR package
Contributor guide
Assessment
This issue has not been assessed yet.