futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Pkg.Types

Contents

- Versions
- Package manifests
- Parsing package manifests
- Build list

Description

Types (and a few other simple definitions) for futhark-pkg.

Synopsis

- type PkgPath = Text
- pkgPathFilePath :: PkgPath -> FilePath
- newtype PkgRevDeps = PkgRevDeps (Map PkgPath (SemVer, Maybe Text))
- data Chunk = Alphanum !Text
- newtype Release = Release (NonEmpty Chunk)
- data SemVer = SemVer {
  - _svMajor :: !Word
  - _svMinor :: !Word
  - _svPatch :: !Word
  - _svPreRel :: !(Maybe Release)
  - _svMeta :: !(Maybe Text)
  }
- prettySemVer :: SemVer -> Text
- commitVersion :: Text -> Text -> SemVer
- isCommitVersion :: SemVer -> Maybe Text
- parseVersion :: Text -> Either (ParseErrorBundle Text Void) SemVer
- data PkgManifest = PkgManifest {
  - manifestPkgPath :: Commented (Maybe PkgPath)
  - manifestRequire :: Commented [Either Comment Required]
  - manifestEndComments :: [Comment]
  }
- newPkgManifest :: Maybe PkgPath -> PkgManifest
- pkgRevDeps :: PkgManifest -> PkgRevDeps
- pkgDir :: PkgManifest -> Maybe FilePath
- addRequiredToManifest :: Required -> PkgManifest -> (PkgManifest, Maybe Required)
- removeRequiredFromManifest :: PkgPath -> PkgManifest -> Maybe (PkgManifest, Required)
- prettyPkgManifest :: PkgManifest -> Text
- type Comment = Text
- data Commented a = Commented {
  - comments :: [Comment]
  - commented :: a
  }
- data Required = Required {
  - requiredPkg :: PkgPath
  - requiredPkgRev :: SemVer
  - requiredHash :: Maybe Text
  }
- futharkPkg :: FilePath
- parsePkgManifest :: FilePath -> Text -> Either (ParseErrorBundle Text Void) PkgManifest
- parsePkgManifestFromFile :: FilePath -> IO PkgManifest
- errorBundlePretty :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> String
- newtype BuildList = BuildList {
  - unBuildList :: Map PkgPath SemVer
  }
- prettyBuildList :: BuildList -> Text

# Documentation

type PkgPath = Text Source #

A package path is a unique identifier for a package, for example `github.comuserfoo`.

pkgPathFilePath :: PkgPath -> FilePath Source #

Turn a package path (which always uses forward slashes) into a file path in the local file system (which might use different slashes).

newtype PkgRevDeps Source #

The dependencies of a (revision of a) package is a mapping from package paths to minimum versions (and an optional hash pinning).

Constructors

PkgRevDeps (Map PkgPath (SemVer, Maybe Text)) |

#### Instances

Instances details

Monoid PkgRevDeps Source # |
Instance details Defined in Futhark.Pkg.Types Methods mempty :: PkgRevDeps Source # mappend :: PkgRevDeps -> PkgRevDeps -> PkgRevDeps Source # mconcat :: [PkgRevDeps] -> PkgRevDeps Source #
Semigroup PkgRevDeps Source # |
Instance details Defined in Futhark.Pkg.Types Methods (<>) :: PkgRevDeps -> PkgRevDeps -> PkgRevDeps Source # sconcat :: NonEmpty PkgRevDeps -> PkgRevDeps Source # stimes :: Integral b => b -> PkgRevDeps -> PkgRevDeps Source #
Show PkgRevDeps Source # |
Instance details Defined in Futhark.Pkg.Types Methods showsPrec :: Int -> PkgRevDeps -> ShowS Source # show :: PkgRevDeps -> String Source # showList :: [PkgRevDeps] -> ShowS Source #

data Chunk Source #

A logical unit of a version number.

Either entirely numerical (with no leading zeroes) or entirely alphanumerical (with a free mixture of numbers, letters, and hyphens.)

Groups of these (like `Release`) are separated by periods to form a full section of a version number.

Examples:

    1
    20150826
    r3
    0rc1-abc3

Constructors

Alphanum !Text |

#### Instances

Instances details

Data Chunk |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Chunk -> c Chunk Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Chunk Source #

toConstr :: Chunk -> Constr Source #

dataTypeOf :: Chunk -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Chunk) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Chunk) Source #

gmapT :: (forall b. Data b => b -> b) -> Chunk -> Chunk Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Chunk -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Chunk -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Chunk -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Chunk -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Chunk -> m Chunk Source #

Generic Chunk |
Instance details Defined in Data.Versions Associated Types type Rep Chunk :: Type -> Type Source # Methods from :: Chunk -> Rep Chunk x Source # to :: Rep Chunk x -> Chunk Source #
Read Chunk |
Instance details Defined in Data.Versions Methods readsPrec :: Int -> ReadS Chunk Source # readList :: ReadS [Chunk] Source # readPrec :: ReadPrec Chunk Source # readListPrec :: ReadPrec [Chunk] Source #
Show Chunk |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Chunk -> ShowS Source # show :: Chunk -> String Source # showList :: [Chunk] -> ShowS Source #
NFData Chunk |
Instance details Defined in Data.Versions Methods rnf :: Chunk -> () Source #
Eq Chunk |
Instance details Defined in Data.Versions Methods (==) :: Chunk -> Chunk -> Bool Source # (/=) :: Chunk -> Chunk -> Bool Source #
Hashable Chunk |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Chunk -> Int hash :: Chunk -> Int
Lift Chunk |
Instance details Defined in Data.Versions Methods lift :: Quote m => Chunk -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Chunk -> Code m Chunk Source #
type Rep Chunk |

Instance details

Defined in Data.Versions

type Rep Chunk = D1 ('MetaData "Chunk" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "Numeric" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word)) :+: C1 ('MetaCons "Alphanum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))

newtype Release Source #

`Chunk`s have comparison behaviour according to SemVer's rules for preleases.

Constructors

Release (NonEmpty Chunk) |

#### Instances

Instances details

Data Release |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Release -> c Release Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Release Source #

toConstr :: Release -> Constr Source #

dataTypeOf :: Release -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Release) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Release) Source #

gmapT :: (forall b. Data b => b -> b) -> Release -> Release Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Release -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Release -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Release -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Release -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Release -> m Release Source #

Generic Release |
Instance details Defined in Data.Versions Associated Types type Rep Release :: Type -> Type Source # Methods from :: Release -> Rep Release x Source # to :: Rep Release x -> Release Source #
Read Release |
Instance details Defined in Data.Versions Methods readsPrec :: Int -> ReadS Release Source # readList :: ReadS [Release] Source # readPrec :: ReadPrec Release Source # readListPrec :: ReadPrec [Release] Source #
Show Release |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> Release -> ShowS Source # show :: Release -> String Source # showList :: [Release] -> ShowS Source #
NFData Release |
Instance details Defined in Data.Versions Methods rnf :: Release -> () Source #
Eq Release |
Instance details Defined in Data.Versions Methods (==) :: Release -> Release -> Bool Source # (/=) :: Release -> Release -> Bool Source #
Ord Release |
Instance details Defined in Data.Versions Methods compare :: Release -> Release -> Ordering Source # (<) :: Release -> Release -> Bool Source # (<=) :: Release -> Release -> Bool Source # (>) :: Release -> Release -> Bool Source # (>=) :: Release -> Release -> Bool Source # max :: Release -> Release -> Release Source # min :: Release -> Release -> Release Source #
Hashable Release |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> Release -> Int hash :: Release -> Int
Lift Release |
Instance details Defined in Data.Versions Methods lift :: Quote m => Release -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Release -> Code m Release Source #
type Rep Release |
Instance details Defined in Data.Versions type Rep Release = D1 ('MetaData "Release" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'True) (C1 ('MetaCons "Release" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Chunk))))

data SemVer Source #

An (Ideal) version number that conforms to Semantic Versioning. This is a prescriptive parser, meaning it follows the SemVer standard.

Legal semvers are of the form: MAJOR.MINOR.PATCH-PREREL+META

Example: `1.2.3-r1+commithash`

Extra Rules:

1. Pre-release versions have lower precedence than normal versions.
2. Build metadata does not affect version precedence.
3. PREREL and META strings may only contain ASCII alphanumerics and hyphens.

For more information, see http://semver.org

Constructors

SemVer |

Fields

- _svMajor :: !Word
- _svMinor :: !Word
- _svPatch :: !Word
- _svPreRel :: !(Maybe Release)
- _svMeta :: !(Maybe Text)

#### Instances

Instances details

Data SemVer |

Instance details

Defined in Data.Versions

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SemVer -> c SemVer Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SemVer Source #

toConstr :: SemVer -> Constr Source #

dataTypeOf :: SemVer -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SemVer) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SemVer) Source #

gmapT :: (forall b. Data b => b -> b) -> SemVer -> SemVer Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SemVer -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SemVer -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SemVer -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SemVer -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SemVer -> m SemVer Source #

Generic SemVer |
Instance details Defined in Data.Versions Associated Types type Rep SemVer :: Type -> Type Source # Methods from :: SemVer -> Rep SemVer x Source # to :: Rep SemVer x -> SemVer Source #
Show SemVer |
Instance details Defined in Data.Versions Methods showsPrec :: Int -> SemVer -> ShowS Source # show :: SemVer -> String Source # showList :: [SemVer] -> ShowS Source #
NFData SemVer |
Instance details Defined in Data.Versions Methods rnf :: SemVer -> () Source #
Eq SemVer | Two SemVers are equal if all fields except metadata are equal.
Instance details Defined in Data.Versions Methods (==) :: SemVer -> SemVer -> Bool Source # (/=) :: SemVer -> SemVer -> Bool Source #
Ord SemVer | Build metadata does not affect version precedence.
Instance details Defined in Data.Versions Methods compare :: SemVer -> SemVer -> Ordering Source # (<) :: SemVer -> SemVer -> Bool Source # (<=) :: SemVer -> SemVer -> Bool Source # (>) :: SemVer -> SemVer -> Bool Source # (>=) :: SemVer -> SemVer -> Bool Source # max :: SemVer -> SemVer -> SemVer Source # min :: SemVer -> SemVer -> SemVer Source #
Hashable SemVer |
Instance details Defined in Data.Versions Methods hashWithSalt :: Int -> SemVer -> Int hash :: SemVer -> Int
Semantic SemVer |
Instance details Defined in Data.Versions Methods major :: Traversal' SemVer Word Source # minor :: Traversal' SemVer Word Source # patch :: Traversal' SemVer Word Source # release :: Traversal' SemVer (Maybe Release) Source # meta :: Traversal' SemVer (Maybe Text) Source # semantic :: Traversal' SemVer SemVer Source #
Lift SemVer |
Instance details Defined in Data.Versions Methods lift :: Quote m => SemVer -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => SemVer -> Code m SemVer Source #
type Rep SemVer |

Instance details

Defined in Data.Versions

type Rep SemVer = D1 ('MetaData "SemVer" "Data.Versions" "versions-6.0.7-5TfSFHOPOSv4r90bqhcICy" 'False) (C1 ('MetaCons "SemVer" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_svMajor") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word) :*: S1 ('MetaSel ('Just "_svMinor") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word)) :*: (S1 ('MetaSel ('Just "_svPatch") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word) :*: (S1 ('MetaSel ('Just "_svPreRel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Release)) :*: S1 ('MetaSel ('Just "_svMeta") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text))))))

prettySemVer :: SemVer -> Text Source #

Convert a `SemVer` back to its textual representation.

# Versions

commitVersion :: Text -> Text -> SemVer Source #

`commitVersion timestamp commit` constructs a commit version.

isCommitVersion :: SemVer -> Maybe Text Source #

Versions of the form (0,0,0)-timestamp+hash are treated specially, as a reference to the commit identified uniquely with `hash` (typically the Git commit ID). This function detects such versions.

parseVersion :: Text -> Either (ParseErrorBundle Text Void) SemVer Source #

Unfortunately, Data.Versions has a buggy semver parser that collapses consecutive zeroes in the metadata field. So, we define our own parser here. It's a little simpler too, since we don't need full semver.

# Package manifests

data PkgManifest Source #

A structure corresponding to a `futhark.pkg` file, including comments. It is an invariant that duplicate required packages do not occcur (the parser will verify this).

Constructors

PkgManifest |

Fields

- manifestPkgPath :: Commented (Maybe PkgPath)

  The name of the package.

- manifestRequire :: Commented [Either Comment Required]
- manifestEndComments :: [Comment]

#### Instances

Instances details

Show PkgManifest Source # |
Instance details Defined in Futhark.Pkg.Types Methods showsPrec :: Int -> PkgManifest -> ShowS Source # show :: PkgManifest -> String Source # showList :: [PkgManifest] -> ShowS Source #
Eq PkgManifest Source # |
Instance details Defined in Futhark.Pkg.Types Methods (==) :: PkgManifest -> PkgManifest -> Bool Source # (/=) :: PkgManifest -> PkgManifest -> Bool Source #

newPkgManifest :: Maybe PkgPath -> PkgManifest Source #

Possibly given a package path, construct an otherwise-empty manifest file.

pkgRevDeps :: PkgManifest -> PkgRevDeps Source #

The required packages listed in a package manifest.

pkgDir :: PkgManifest -> Maybe FilePath Source #

Where in the corresponding repository archive we can expect to find the package files.

addRequiredToManifest :: Required -> PkgManifest -> (PkgManifest, Maybe Required) Source #

Add new required package to the package manifest. If the package was already present, return the old version.

removeRequiredFromManifest :: PkgPath -> PkgManifest -> Maybe (PkgManifest, Required) Source #

Remove a required package from the manifest. Returns `Nothing` if the package was not found in the manifest, and otherwise the new manifest and the `Required` that was present.

prettyPkgManifest :: PkgManifest -> Text Source #

Prettyprint a package manifest such that it can be written to a `futhark.pkg` file.

type Comment = Text Source #

A line comment.

data Commented a Source #

Wraps a value with an annotation of preceding line comments. This is important to our goal of being able to programmatically modify the `futhark.pkg` file while keeping comments intact.

Constructors

Commented |

Fields

- comments :: [Comment]
- commented :: a

#### Instances

Instances details

Foldable Commented Source # |

Instance details

Defined in Futhark.Pkg.Types

Methods

fold :: Monoid m => Commented m -> m Source #

foldMap :: Monoid m => (a -> m) -> Commented a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Commented a -> m Source #

foldr :: (a -> b -> b) -> b -> Commented a -> b Source #

foldr' :: (a -> b -> b) -> b -> Commented a -> b Source #

foldl :: (b -> a -> b) -> b -> Commented a -> b Source #

foldl' :: (b -> a -> b) -> b -> Commented a -> b Source #

foldr1 :: (a -> a -> a) -> Commented a -> a Source #

foldl1 :: (a -> a -> a) -> Commented a -> a Source #

toList :: Commented a -> [a] Source #

null :: Commented a -> Bool Source #

length :: Commented a -> Int Source #

elem :: Eq a => a -> Commented a -> Bool Source #

maximum :: Ord a => Commented a -> a Source #

minimum :: Ord a => Commented a -> a Source #

sum :: Num a => Commented a -> a Source #

product :: Num a => Commented a -> a Source #

Traversable Commented Source # |
Instance details Defined in Futhark.Pkg.Types Methods traverse :: Applicative f => (a -> f b) -> Commented a -> f (Commented b) Source # sequenceA :: Applicative f => Commented (f a) -> f (Commented a) Source # mapM :: Monad m => (a -> m b) -> Commented a -> m (Commented b) Source # sequence :: Monad m => Commented (m a) -> m (Commented a) Source #
Functor Commented Source # |
Instance details Defined in Futhark.Pkg.Types Methods fmap :: (a -> b) -> Commented a -> Commented b Source # (<$) :: a -> Commented b -> Commented a Source #
Show a => Show (Commented a) Source # |
Instance details Defined in Futhark.Pkg.Types Methods showsPrec :: Int -> Commented a -> ShowS Source # show :: Commented a -> String Source # showList :: [Commented a] -> ShowS Source #
Eq a => Eq (Commented a) Source # |
Instance details Defined in Futhark.Pkg.Types Methods (==) :: Commented a -> Commented a -> Bool Source # (/=) :: Commented a -> Commented a -> Bool Source #

data Required Source #

An entry in the `required` section of a `futhark.pkg` file.

Constructors

Required |

Fields

- requiredPkg :: PkgPath

  Name of the required package.

- requiredPkgRev :: SemVer

  The minimum revision.

- requiredHash :: Maybe Text

  An optional hash indicating what this revision looked like the last time we saw it. Used for integrity checking.

#### Instances

Instances details

Show Required Source # |
Instance details Defined in Futhark.Pkg.Types Methods showsPrec :: Int -> Required -> ShowS Source # show :: Required -> String Source # showList :: [Required] -> ShowS Source #
Eq Required Source # |
Instance details Defined in Futhark.Pkg.Types Methods (==) :: Required -> Required -> Bool Source # (/=) :: Required -> Required -> Bool Source #

futharkPkg :: FilePath Source #

The name of the file containing the futhark-pkg manifest.

# Parsing package manifests

parsePkgManifest :: FilePath -> Text -> Either (ParseErrorBundle Text Void) PkgManifest Source #

Parse a pretty as a `PkgManifest`. The `FilePath` is used for any error messages.

parsePkgManifestFromFile :: FilePath -> IO PkgManifest Source #

Read contents of file and pass it to `parsePkgManifest`.

errorBundlePretty Source #

Arguments

:: (VisualStream s, TraversableStream s, ShowErrorComponent e) |
=> ParseErrorBundle s e | Parse error bundle to display
-> String | Textual rendition of the bundle

Pretty-print a `ParseErrorBundle`. All `ParseError`s in the bundle will be pretty-printed in order together with the corresponding offending lines by doing a single pass over the input stream. The rendered `String` always ends with a newline.

Since: megaparsec-7.0.0

# Build list

newtype BuildList Source #

A mapping from package paths to their chosen revisions. This is the result of the version solver.

Constructors

BuildList |

Fields

- unBuildList :: Map PkgPath SemVer

#### Instances

Instances details

Show BuildList Source # |
Instance details Defined in Futhark.Pkg.Types Methods showsPrec :: Int -> BuildList -> ShowS Source # show :: BuildList -> String Source # showList :: [BuildList] -> ShowS Source #
Eq BuildList Source # |
Instance details Defined in Futhark.Pkg.Types Methods (==) :: BuildList -> BuildList -> Bool Source # (/=) :: BuildList -> BuildList -> Bool Source #

prettyBuildList :: BuildList -> Text Source #

Prettyprint a build list; one package per line and newline-terminated.