Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Refactor Target #207

Closed
snowleopard opened this issue Feb 10, 2016 · 2 comments
Closed

Refactor Target #207

snowleopard opened this issue Feb 10, 2016 · 2 comments
Assignees

Comments

@snowleopard
Copy link
Owner

We currently have the following Target datatype:

-- | Parameters relevant to the current build target.
data Target = Target
    { stage   :: Stage      -- ^ Stage being built
    , package :: Package    -- ^ Package being built
    , builder :: Builder    -- ^ Builder to be invoked
    , way     :: Way        -- ^ Way to build (set to vanilla for most targets)
    , inputs  :: [FilePath] -- ^ Source files passed to the builder
    , outputs :: [FilePath] -- ^ Files to be produced
    } deriving (Show, Eq, Generic)

It makes sense to factor out Stage, Package and Way into a separate datatype called Context:

  • At the moment we mix different notions in one datatype: target-specific ones (builder, inputs, outputs) and context-specific ones (what is the current stage, package and way?).

  • By factoring out GHC-specific bits into Context we make it easier to reuse our build abstractions in other build systems. Arguably, builder, inputs and outputs are common for all non-trivial build systems, however, not all build systems need way, package or, especially, stage.

  • We already have a datatype called PartialTarget in the build system:

    -- | A partially constructed Target with fields 'Stage' and 'Package' only.
    -- 'PartialTarget's are used for generating build rules.
    data PartialTarget = PartialTarget Stage Package deriving (Eq, Show)

    This is almost exactly what we want to have as a Context.

/cc @simonpj @simonmar @ndmitchell

@ndmitchell
Copy link
Collaborator

Seems reasonable to me. Will we be able to kill PartialTarget afterwards?

@snowleopard
Copy link
Owner Author

@ndmitchell Yes, I think so. It will be consumed by Context.

snowleopard added a commit that referenced this issue Feb 12, 2016
snowleopard added a commit that referenced this issue Feb 16, 2016
snowleopard added a commit that referenced this issue Feb 16, 2016
snowleopard added a commit that referenced this issue Feb 16, 2016
snowleopard added a commit that referenced this issue Feb 19, 2016
snowleopard added a commit that referenced this issue Feb 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants