Skip to content

Proposed redesign of LocalBuildInfo and BuildTarget interface #3589

Closed

Description

@ezyang

While working in the Cabal codebase, I noticed that we repeatedly want to treat these types as interconvertible: ComponentName, Component, ComponentLocalBuildInfo. There are two problems:

  1. We keep doing goofy things like use the ComponentName to get the Component, then throw it out and later retrieve the Component again. Each of these is a linear scan over the components of the package description! So everything is inconvenient forever. Or we have finally gotten to a ComponentLocalBuildInfo, but then we want the ComponentName again.
  2. It's not right in the Backpack world to treat ComponentLocalBuildInfo as interchangeable with ComponentName; the same component might get built multiple times.
  3. BuildTarget goes through the trouble of getting out a module/filename that specifically was requested, at which point it is promptly discarded.

So, I propose we create a new data structure to bundle together Component, ComponentLocalBuildInfo, and the file target, and then consistently apply it to all functions in LocalBuildInfo right now. Let's call it TargetInfo. For example, componentsInBuildOrder can now get a new variant targetsInBuildOrder which deals in TargetInfos rather than ComponentLocalBuildInfos.

I think this should have minimal BC concerns, because it is an easy matter to keep all the old functions around.

Activity

  1. 23Skidoo commented on Jul 22, 2016

    @23Skidoo
    Member

    Sounds sensible to me.
    /cc @dcoutts

  2. ezyang commented on Jul 22, 2016

    @ezyang
    ContributorAuthor

    PR in #3595

  3. jneira commented on Jul 13, 2021

    @jneira
    Member

    The mentioned pr is merged so I suppose this can be closed, @ezyang feel free to reopen if that is not the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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