Skip to content

Why does Stack rebuild unrelated source files? What are the recommended project structures? #6382

@SmartHypercube

Description

@SmartHypercube

Example repo: https://github.com/SmartHypercube/aoc2023-haskell

When I add another executable (by adding an executable in package.yaml and adding a file in src directory), and run stack run <new executable name>, Stack rebuilds all other executables. I would like to know why does this happen. I guess it is because I used a bad project structure, but I have tried some other ways to organized the files and directories, and each structure has its own problems.

I wish Stack could provide some tips about how should people organize project files for different types of projects (e.g. 1 lib + 1 exe, 1 lib + many exe, 0 lib + many exe, etc.). A good project structure should mean that adding / removing / updating source files should always result in the minimum set of files recompiled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions