Skip to content

Improve module structure for faster builds and better separation of concerns #2334

@sjakobi

Description

@sjakobi

A few ideas:

Delete Stack.Types

The modules would then only depend on the Stack.Types.* modules that they actually need and e.g. Stack.Clean wouldn't have to be recompiled after a change in Stack.Types.Nix.

Split up Stack.Options and move option parsers to option types

Because Stack.Options has a lot of dependencies it is currently recompiled after most changes.
Splitting it up would also make changes on option types more localized.

But maybe I just don't understand the original motivation for introducing that module.

Generally move types into the Stack.Types.* modules

Particularly types with a lot of (derived) instances take rather long to compile.

Split up Stack.Types.Config

This module takes a really long time to compile. And why are types like PackageIndex not in Stack.Types.PackageIndex?

The structure that I added in #1326 should probably be largely disregarded. I didn't really understand the various types at that time.

Move commands out of Main

I think it would be really nice if all code that is specific for a command could be defined in the same module (and a separate types module ;)). E.g. I wish that in Stack.Clean I could define something like

cleanCommand :: Command CleanOpts
cleanCommand = Command
    { commandName = "clean"
    , commandDescription = "Delete build artifacts in the current project"
    , commandAction = withEnvConfigNoLock (\globalOpts cleanOpts -> clean cleanOpts)
    , commandOptsParser = cleanOptsParser
    , commandAvailableInInterpreterMode = False
    }

In order not to introduce a dependency on Stack.Setup, withEnvConfigNoLock would only be a smart constructor for some datatype that defines actions that run in the various StackT environments.

Delete unnecessary instances

(Included because it impacts the compile times)
E.g. why does ConfigMonoid need a Show instance?

Thoughts?

Do these ideas maybe run counter to other goals for stack?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions