Copyright | (c) Julian Ospald 2020 |
---|---|
License | LGPL-3.0 |
Maintainer | hasufell@hasufell.de |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
This module contains GHCup helpers specific to installation and introspection of files/versions etc.
Synopsis
- module GHCup.Utils.Dirs
- ghcLinkDestination :: (MonadReader AppState m, MonadThrow m, MonadIO m) => ByteString -> GHCTargetVersion -> m ByteString
- rmMinorSymlinks :: (MonadReader AppState m, MonadIO m, MonadLogger m, MonadThrow m, MonadFail m, MonadReader AppState m) => GHCTargetVersion -> Excepts '[NotInstalled] m ()
- rmPlain :: (MonadReader AppState m, MonadLogger m, MonadThrow m, MonadFail m, MonadIO m) => Maybe Text -> Excepts '[NotInstalled] m ()
- rmMajorSymlinks :: (MonadReader AppState m, MonadIO m, MonadLogger m, MonadThrow m, MonadFail m, MonadReader AppState m) => GHCTargetVersion -> Excepts '[NotInstalled] m ()
- ghcInstalled :: (MonadIO m, MonadReader AppState m, MonadThrow m) => GHCTargetVersion -> m Bool
- ghcSrcInstalled :: (MonadIO m, MonadReader AppState m, MonadThrow m) => GHCTargetVersion -> m Bool
- ghcSet :: (MonadReader AppState m, MonadThrow m, MonadIO m) => Maybe Text -> m (Maybe GHCTargetVersion)
- ghcLinkVersion :: MonadThrow m => ByteString -> m GHCTargetVersion
- getInstalledGHCs :: (MonadReader AppState m, MonadIO m) => m [Either (Path Rel) GHCTargetVersion]
- getInstalledCabals :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadCatch m) => m [Either (Path Rel) Version]
- getInstalledCabals' :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadCatch m) => Maybe Version -> m [Either (Path Rel) Version]
- cabalInstalled :: (MonadLogger m, MonadIO m, MonadReader AppState m, MonadCatch m) => Version -> m Bool
- cabalSet :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m (Maybe Version)
- getInstalledHLSs :: (MonadReader AppState m, MonadIO m, MonadCatch m) => m [Either (Path Rel) Version]
- hlsInstalled :: (MonadIO m, MonadReader AppState m, MonadCatch m) => Version -> m Bool
- hlsSet :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m (Maybe Version)
- hlsGHCVersions :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m [Version]
- hlsServerBinaries :: (MonadReader AppState m, MonadIO m) => Version -> m [Path Rel]
- hlsWrapperBinary :: (MonadReader AppState m, MonadThrow m, MonadIO m) => Version -> m (Maybe (Path Rel))
- hlsAllBinaries :: (MonadReader AppState m, MonadIO m, MonadThrow m) => Version -> m [Path Rel]
- hlsSymlinks :: (MonadReader AppState m, MonadIO m, MonadCatch m) => m [Path Rel]
- getMajorMinorV :: MonadThrow m => Version -> m (Int, Int)
- matchMajor :: Version -> Int -> Int -> Bool
- getGHCForMajor :: (MonadReader AppState m, MonadIO m, MonadThrow m) => Int -> Int -> Maybe Text -> m (Maybe GHCTargetVersion)
- getLatestGHCFor :: Int -> Int -> GHCupDownloads -> Maybe (Version, VersionInfo)
- unpackToDir :: (MonadLogger m, MonadIO m, MonadThrow m) => Path Abs -> Path Abs -> Excepts '[UnknownArchive, ArchiveResult] m ()
- getArchiveFiles :: (MonadLogger m, MonadIO m, MonadThrow m) => Path Abs -> Excepts '[UnknownArchive, ArchiveResult] m [ByteString]
- intoSubdir :: (MonadLogger m, MonadIO m, MonadThrow m, MonadCatch m) => Path Abs -> TarDir -> Excepts '[TarDirDoesNotExist] m (Path Abs)
- getTagged :: Tag -> AffineFold (Map Version VersionInfo) (Version, VersionInfo)
- getLatest :: GHCupDownloads -> Tool -> Maybe (Version, VersionInfo)
- getRecommended :: GHCupDownloads -> Tool -> Maybe (Version, VersionInfo)
- getLatestBaseVersion :: GHCupDownloads -> PVP -> Maybe (Version, VersionInfo)
- getCache :: MonadReader AppState m => m Bool
- getDownloader :: MonadReader AppState m => m Downloader
- urlBaseName :: MonadThrow m => ByteString -> m (Path Rel)
- ghcToolFiles :: (MonadReader AppState m, MonadThrow m, MonadFail m, MonadIO m) => GHCTargetVersion -> Excepts '[NotInstalled] m [Path Rel]
- ghcUpSrcBuiltFile :: Path Rel
- make :: (MonadThrow m, MonadIO m, MonadReader AppState m) => [ByteString] -> Maybe (Path Abs) -> m (Either ProcessError ())
- applyPatches :: (MonadLogger m, MonadIO m) => Path Abs -> Path Abs -> Excepts '[PatchFailed] m ()
- darwinNotarization :: Platform -> Path Abs -> IO (Either ProcessError ())
- getChangeLog :: GHCupDownloads -> Tool -> Either Version Tag -> Maybe URI
- runBuildAction :: (Show (V e), MonadReader AppState m, MonadIO m, MonadMask m) => Path Abs -> Maybe (Path Abs) -> Excepts e m a -> Excepts '[BuildFailed] m a
- createDirRecursive' :: Path b -> IO ()
- getVersionInfo :: Version -> Tool -> GHCupDownloads -> Maybe VersionInfo
- traverseFold :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b
- forFold :: (Foldable t, Applicative m, Monoid b) => t a -> (a -> m b) -> m b
Documentation
module GHCup.Utils.Dirs
:: (MonadReader AppState m, MonadThrow m, MonadIO m) | |
=> ByteString | the tool, such as |
-> GHCTargetVersion | |
-> m ByteString |
The symlink destination of a ghc tool.
rmMinorSymlinks :: (MonadReader AppState m, MonadIO m, MonadLogger m, MonadThrow m, MonadFail m, MonadReader AppState m) => GHCTargetVersion -> Excepts '[NotInstalled] m () Source #
Removes the minor GHC symlinks, e.g. ghc-8.6.5.
:: (MonadReader AppState m, MonadLogger m, MonadThrow m, MonadFail m, MonadIO m) | |
=> Maybe Text | target |
-> Excepts '[NotInstalled] m () |
Removes the set ghc version for the given target, if any.
rmMajorSymlinks :: (MonadReader AppState m, MonadIO m, MonadLogger m, MonadThrow m, MonadFail m, MonadReader AppState m) => GHCTargetVersion -> Excepts '[NotInstalled] m () Source #
Remove the major GHC symlink, e.g. ghc-8.6.
ghcInstalled :: (MonadIO m, MonadReader AppState m, MonadThrow m) => GHCTargetVersion -> m Bool Source #
Whethe the given GHC versin is installed.
ghcSrcInstalled :: (MonadIO m, MonadReader AppState m, MonadThrow m) => GHCTargetVersion -> m Bool Source #
Whether the given GHC version is installed from source.
:: (MonadReader AppState m, MonadThrow m, MonadIO m) | |
=> Maybe Text | the target of the GHC version, if any (e.g. armv7-unknown-linux-gnueabihf) |
-> m (Maybe GHCTargetVersion) |
Whether the given GHC version is set as the current.
ghcLinkVersion :: MonadThrow m => ByteString -> m GHCTargetVersion Source #
getInstalledGHCs :: (MonadReader AppState m, MonadIO m) => m [Either (Path Rel) GHCTargetVersion] Source #
Get all installed GHCs by reading ~.ghcupghc/dir. If a dir cannot be parsed, returns left.
getInstalledCabals :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadCatch m) => m [Either (Path Rel) Version] Source #
Get all installed cabals, by matching on ~/.ghcup/bin/cabal-*
.
getInstalledCabals' :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadCatch m) => Maybe Version -> m [Either (Path Rel) Version] Source #
cabalInstalled :: (MonadLogger m, MonadIO m, MonadReader AppState m, MonadCatch m) => Version -> m Bool Source #
Whether the given cabal version is installed.
cabalSet :: (MonadLogger m, MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m (Maybe Version) Source #
getInstalledHLSs :: (MonadReader AppState m, MonadIO m, MonadCatch m) => m [Either (Path Rel) Version] Source #
Get all installed hls, by matching on
~/.ghcup/bin/haskell-language-server-wrapper-hlsver
.
hlsInstalled :: (MonadIO m, MonadReader AppState m, MonadCatch m) => Version -> m Bool Source #
Whether the given HLS version is installed.
hlsSet :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m (Maybe Version) Source #
hlsGHCVersions :: (MonadReader AppState m, MonadIO m, MonadThrow m, MonadCatch m) => m [Version] Source #
Return the GHC versions the currently selected HLS supports.
hlsServerBinaries :: (MonadReader AppState m, MonadIO m) => Version -> m [Path Rel] Source #
Get all server binaries for an hls version, if any.
hlsWrapperBinary :: (MonadReader AppState m, MonadThrow m, MonadIO m) => Version -> m (Maybe (Path Rel)) Source #
Get the wrapper binary for an hls version, if any.
hlsAllBinaries :: (MonadReader AppState m, MonadIO m, MonadThrow m) => Version -> m [Path Rel] Source #
Get all binaries for an hls version, if any.
hlsSymlinks :: (MonadReader AppState m, MonadIO m, MonadCatch m) => m [Path Rel] Source #
Get the active symlinks for hls.
getMajorMinorV :: MonadThrow m => Version -> m (Int, Int) Source #
Extract (major, minor) from any version.
:: (MonadReader AppState m, MonadIO m, MonadThrow m) | |
=> Int | major version component |
-> Int | minor version component |
-> Maybe Text | the target triple |
-> m (Maybe GHCTargetVersion) |
Get the latest installed full GHC version that satisfies X.Y.
This reads ghcupGHCBaseDir
.
:: Int | major version component |
-> Int | minor version component |
-> GHCupDownloads | |
-> Maybe (Version, VersionInfo) |
Get the latest available ghc for X.Y major version.
:: (MonadLogger m, MonadIO m, MonadThrow m) | |
=> Path Abs | destination dir |
-> Path Abs | archive path |
-> Excepts '[UnknownArchive, ArchiveResult] m () |
Unpack an archive to a temporary directory and return that path.
:: (MonadLogger m, MonadIO m, MonadThrow m) | |
=> Path Abs | archive path |
-> Excepts '[UnknownArchive, ArchiveResult] m [ByteString] |
:: (MonadLogger m, MonadIO m, MonadThrow m, MonadCatch m) | |
=> Path Abs | unpacked tar dir |
-> TarDir | how to descend |
-> Excepts '[TarDirDoesNotExist] m (Path Abs) |
getTagged :: Tag -> AffineFold (Map Version VersionInfo) (Version, VersionInfo) Source #
Get the tool version that has this tag. If multiple have it, picks the greatest version.
getLatest :: GHCupDownloads -> Tool -> Maybe (Version, VersionInfo) Source #
getRecommended :: GHCupDownloads -> Tool -> Maybe (Version, VersionInfo) Source #
getLatestBaseVersion :: GHCupDownloads -> PVP -> Maybe (Version, VersionInfo) Source #
Gets the latest GHC with a given base version.
getDownloader :: MonadReader AppState m => m Downloader Source #
:: MonadThrow m | |
=> ByteString | the url path (without scheme and host) |
-> m (Path Rel) |
ghcToolFiles :: (MonadReader AppState m, MonadThrow m, MonadFail m, MonadIO m) => GHCTargetVersion -> Excepts '[NotInstalled] m [Path Rel] Source #
Get tool files from ~/.ghcup/bin/ghc/<ver>/bin/*
while ignoring *-<ver>
symlinks and accounting for cross triple prefix.
Returns unversioned relative files, e.g.:
["hsc2hs","haddock","hpc","runhaskell","ghc","ghc-pkg","ghci","runghc","hp2ps"]
ghcUpSrcBuiltFile :: Path Rel Source #
This file, when residing in ~/.ghcup/ghc/<ver>/
signals that
this GHC was built from source. It contains the build config.
make :: (MonadThrow m, MonadIO m, MonadReader AppState m) => [ByteString] -> Maybe (Path Abs) -> m (Either ProcessError ()) Source #
Calls gmake if it exists in PATH, otherwise make.
:: (MonadLogger m, MonadIO m) | |
=> Path Abs | dir containing patches |
-> Path Abs | dir to apply patches in |
-> Excepts '[PatchFailed] m () |
Try to apply patches in order. Fails with PatchFailed
on first failure.
darwinNotarization :: Platform -> Path Abs -> IO (Either ProcessError ()) Source #
getChangeLog :: GHCupDownloads -> Tool -> Either Version Tag -> Maybe URI Source #
:: (Show (V e), MonadReader AppState m, MonadIO m, MonadMask m) | |
=> Path Abs | build directory (cleaned up depending on Settings) |
-> Maybe (Path Abs) | dir to *always* clean up on exception |
-> Excepts e m a | |
-> Excepts '[BuildFailed] m a |
Execute a build action while potentially cleaning up:
- the build directory, depending on the KeepDirs setting
- the install destination, depending on whether the build failed
createDirRecursive' :: Path b -> IO () Source #
More permissive version of createDirRecursive
. This doesn't
error when the destination is a symlink to a directory.
getVersionInfo :: Version -> Tool -> GHCupDownloads -> Maybe VersionInfo Source #
traverseFold :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b Source #