Skip to content

Stackage.Package #5

Closed
Closed

Description

@chrisdone

So we already have an implementation of this in stackage-common but under slightly different superficial arguments. We'd like it updated to match the proposal (see end of ticket). Currently,

getPackage :: FinalAction
         -> Map Text Bool
         -> Map PackageName (Map Text Bool)
         -> Loc Absolute File
         -> IO Package

the two flag structure arguments are redundant, it can be just one. And the final action is remnant from fpbuild, it's really only used to determine whether the test suite or benchmarks are enabled. So these things can be put in a PackageConfig record data type (as below). It should just be a case of updating the places that need to be updated to enforce this API.

You can this along with your stackage-curator stuff and then pass to me and I'll port stackage-build to the latest stackage-common API and update anything as necessary.

-- | Anything to do with a package associated with some directory.
module Stackage.Package where
data PackageException
data Package = Package
  {packageName :: !PackageName
  ,packageVersion :: !PackageVersion
  ,packageDir :: !FilePath
  ,packageFiles :: !(Set FilePath)
  ,packageDependencies :: !(Map PackageName VersionRange)
  ,packageTools :: !(Set Tool)
  ,packageFlags :: !(Map Text Bool)}
data BuildResult
data PackageConfig = PackageConfig
  { packageConfigEnableTests :: !Bool
  , packageConfigEnableBenchmarks :: !Bool
  , packageConfigFlags :: !Map Text Bool
  }
readPackage :: (MonadLogger m,MonadIO m,MonadThrow m)
            => PackageConfig -> Loc Absolute File -> m Package

Activity

  1. drwebb commented on May 6, 2015

    @drwebb
    Contributor

    I've made the changes to Stackage.Package in commit 1b13a3d just to match the API for readPackage. Is PackageException a straight rename of FPException? And, I need details how what BuildResult should look like.

    There are a few more functions in #1 that I haven't implemented/refactored

    buildPackage :: (MonadLogger m,MonadIO m,MonadThrow m)
                 => Package -> m BuildResult
    testPackage :: (MonadLogger m,MonadIO m,MonadThrow m)
                => Package -> m TestResult
    copyPackage :: (MonadLogger m,MonadIO m,MonadThrow m)
                => Package -> m ()
    registerPackage :: (MonadLogger m,MonadIO m,MonadThrow m)
                    => Package -> m ()
  2. chrisdone commented on May 6, 2015

    @chrisdone
    MemberAuthor

    Is PackageException a straight rename of FPException?

    Yep.

    And, I need details how what BuildResult should look like.

    The build/test/copy/register commands you can leave out (I purposely didn't include them in this ticket) unless you need them for your work right now. They will require extracting the code from stackage-build/src/Stackage/Build.hs, which is probably most efficient for me to do as I'm familliar with it and there's a lot of it. Made an issue for that in #6.

  3. drwebb commented on May 7, 2015

    @drwebb
    Contributor

    Running this by you to see if this naming looks good. I can then merge and then mark this issue closed.

    data PackageException
      = PackageConfigError ParseException
      | PackageNoConfigFile
      | PackageNoCabalFile (Loc Absolute Dir)
      | PackageInvalidCabalFile (Loc Absolute File) PError
      | PackageNoDeps (Loc Absolute File)
      | PackageDepCycle PackageName
      | PackageMissingDep Package PackageName VersionRange
      | PackageDependencyIssues [PackageException]
      | PackageMissingTool Dependency
      | PackageCouldn'tFindPkgId PackageName
      | PackageStackagePackageVersionMismatch PackageName Version Version
      | PackageStackageDepVerMismatch PackageName Version VersionRange
      deriving (Show,Typeable)
    instance Exception PackageException
    
  4. chrisdone commented on May 7, 2015

    @chrisdone
    MemberAuthor

    Yep, nice!

  5. drwebb commented on May 7, 2015

    @drwebb
    Contributor

    done, closing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions