ghcup-0.1.14.2: ghc toolchain installer
Copyright(c) Julian Ospald 2020
LicenseLGPL-3.0
Maintainerhasufell@hasufell.de
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

GHCup.Utils

Description

This module contains GHCup helpers specific to installation and introspection of files/versions etc.

Synopsis

Documentation

ghcLinkDestination Source #

Arguments

:: (MonadReader AppState m, MonadThrow m, MonadIO m) 
=> ByteString

the tool, such as ghc, haddock etc.

-> 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.

rmPlain Source #

Arguments

:: (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.

ghcSet Source #

Arguments

:: (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.

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-*.

cabalInstalled :: (MonadLogger m, MonadIO m, MonadReader AppState m, MonadCatch m) => Version -> m Bool Source #

Whether the given cabal version is installed.

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.

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.

getGHCForMajor Source #

Arguments

:: (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.

getLatestGHCFor Source #

Arguments

:: Int

major version component

-> Int

minor version component

-> GHCupDownloads 
-> Maybe (Version, VersionInfo) 

Get the latest available ghc for X.Y major version.

unpackToDir Source #

Arguments

:: (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.

intoSubdir Source #

Arguments

:: (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.

getLatestBaseVersion :: GHCupDownloads -> PVP -> Maybe (Version, VersionInfo) Source #

Gets the latest GHC with a given base version.

urlBaseName Source #

Arguments

:: 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.

applyPatches Source #

Arguments

:: (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.

runBuildAction Source #

Arguments

:: (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:

  1. the build directory, depending on the KeepDirs setting
  2. 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.

traverseFold :: (Foldable t, Applicative m, Monoid b) => (a -> m b) -> t a -> m b Source #

forFold :: (Foldable t, Applicative m, Monoid b) => t a -> (a -> m b) -> m b Source #

Gathering monoidal values