| Copyright | (c) 2020-2021 berberman |
|---|---|
| License | MIT |
| Maintainer | berberman <berberman@yandex.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Distribution.ArchHs.Name
Description
Naming conversion between haskell package in hackage and archlinux community repo.
To distribute a haskell package to archlinux, the name of package should be changed according to the naming convention:
- for haskell libraries, their names must have
haskell-prefix - for programs, it depends on circumstances
- names should always be in lower case
However, it's not enough to prefix the string with haskell- and trasform to lower case; in some special situations, the hackage name
may have haskell- prefix already, or the case is irregular, thus we have to a name preset, NAME_PRESET.json, manually.
Once a package distributed to archlinux, whose name conform to above-mentioned situation, the name preset should be upgraded correspondingly.
NAME_PRESET.json will be loaded during the compilation, generating haskell code to be called in runtime.
Converting a archlinux community name to hackage name following these steps:
- Find if the name preset contains this rule
- If it contains, then use it; or remove the
haskell-prefix
Converting a hackage name to archlinux community name following these steps:
- Find if the name preset contains this rule
- If it contains, then use it; or add the
haskell-prefix
For details, see the type MyName and type class HasMyName with its instances.
Synopsis
- data MyName a
- data NameRep
- class HasMyName a where
- toHackageRep :: a -> MyName 'HackageRep
- toArchLinuxRep :: a -> MyName 'ArchLinuxRep
- toArchLinuxName :: HasMyName n => n -> ArchLinuxName
- toHackageName :: HasMyName n => n -> PackageName
- isHaskellPackage :: ArchLinuxName -> Bool
- isGHCLibs :: PackageName -> Bool
Documentation
A general package name representation.
It has a phantom a, which indexes this name.
Normally, the index should be the data kinds of NameRep.
In Cabal API, packages' names are represented by the type PackageName;
in arch-hs, names parsed from community.db are represented by the type ArchLinuxName.
It would be tedious to use two converting functions everywhere, so here comes a intermediate data type
to unify them, with type level constraints as bonus.
Instances
| Eq (MyName a) Source # | |
| Ord (MyName a) Source # | |
Defined in Distribution.ArchHs.Name | |
| Read (MyName a) Source # | |
| Show (MyName a) Source # | |
| IsString (MyName a) Source # | |
Defined in Distribution.ArchHs.Name Methods fromString :: String -> MyName a # | |
| Generic (MyName a) Source # | |
| NFData (MyName a) Source # | |
Defined in Distribution.ArchHs.Name | |
| HasMyName (MyName 'ArchLinuxRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'ArchLinuxRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'ArchLinuxRep -> MyName 'ArchLinuxRep Source # | |
| HasMyName (MyName 'HackageRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'HackageRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'HackageRep -> MyName 'ArchLinuxRep Source # | |
| type Rep (MyName a) Source # | |
Defined in Distribution.ArchHs.Name | |
The representation of a package name.
Constructors
| ArchLinuxRep | archlinx community style |
| HackageRep | hackage style |
Instances
| HasMyName (MyName 'ArchLinuxRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'ArchLinuxRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'ArchLinuxRep -> MyName 'ArchLinuxRep Source # | |
| HasMyName (MyName 'HackageRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'HackageRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'HackageRep -> MyName 'ArchLinuxRep Source # | |
class HasMyName a where Source #
HasMyName indicates that the type a can be converted to MyName.
This is where the actually conversion occurs.
Methods
toHackageRep :: a -> MyName 'HackageRep Source #
To MyName in hackage style.
toArchLinuxRep :: a -> MyName 'ArchLinuxRep Source #
To MyName in community style.
Instances
| HasMyName PackageName Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: PackageName -> MyName 'HackageRep Source # toArchLinuxRep :: PackageName -> MyName 'ArchLinuxRep Source # | |
| HasMyName ArchLinuxName Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: ArchLinuxName -> MyName 'HackageRep Source # toArchLinuxRep :: ArchLinuxName -> MyName 'ArchLinuxRep Source # | |
| HasMyName (MyName 'ArchLinuxRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'ArchLinuxRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'ArchLinuxRep -> MyName 'ArchLinuxRep Source # | |
| HasMyName (MyName 'HackageRep) Source # | |
Defined in Distribution.ArchHs.Name Methods toHackageRep :: MyName 'HackageRep -> MyName 'HackageRep Source # toArchLinuxRep :: MyName 'HackageRep -> MyName 'ArchLinuxRep Source # | |
toArchLinuxName :: HasMyName n => n -> ArchLinuxName Source #
Convert n to ArchLinuxName.
toHackageName :: HasMyName n => n -> PackageName Source #
Convert n to PackageName.
isHaskellPackage :: ArchLinuxName -> Bool Source #
Check if a package in archlinux community repo is haskell package.
i.e. it is in preset or has haskell- prefix.
Attention: There is no guarantee that the package exists in hackage.
isGHCLibs :: PackageName -> Bool Source #
Check if a package is GHC or GHC Libs