{-# LANGUAGE DeriveGeneric #-} module GHCup.Types where import Data.Map.Strict ( Map ) import Data.Text ( Text ) import Data.Versions import HPath import URI.ByteString import qualified GHC.Generics as GHC data Settings = Settings { cache :: Bool , urlSource :: URLSource , noVerify :: Bool } deriving Show data DebugInfo = DebugInfo { diBaseDir :: Path Abs , diBinDir :: Path Abs , diGHCDir :: Path Abs , diCacheDir :: Path Abs , diURLSource :: URLSource , diArch :: Architecture , diPlatform :: PlatformResult } deriving Show data SetGHC = SetGHCOnly -- ^ unversioned 'ghc' | SetGHCMajor -- ^ ghc-x.y | SetGHCMinor -- ^ ghc-x.y.z -- TODO: rename deriving (Eq, Show) data Tag = Latest | Recommended deriving (Ord, Eq, Show) data VersionInfo = VersionInfo { _viTags :: [Tag] , _viArch :: ArchitectureSpec } deriving (Eq, Show) data DownloadInfo = DownloadInfo { _dlUri :: URI , _dlSubdir :: Maybe (Path Rel) , _dlHash :: Text } deriving (Eq, Show) data Tool = GHC | GHCSrc | Cabal | GHCup deriving (Eq, GHC.Generic, Ord, Show) data ToolRequest = ToolRequest { _trTool :: Tool , _trVersion :: Version } deriving (Eq, Show) data Architecture = A_64 | A_32 deriving (Eq, GHC.Generic, Ord, Show) data LinuxDistro = Debian | Ubuntu | Mint | Fedora | CentOS | RedHat | Alpine | AmazonLinux -- rolling | Gentoo | Exherbo -- not known | UnknownLinux -- ^ must exit deriving (Eq, GHC.Generic, Ord, Show) data Platform = Linux LinuxDistro -- ^ must exit | Darwin -- ^ must exit | FreeBSD deriving (Eq, GHC.Generic, Ord, Show) data PlatformResult = PlatformResult { _platform :: Platform , _distroVersion :: Maybe Versioning } deriving (Eq, Show) data PlatformRequest = PlatformRequest { _rArch :: Architecture , _rPlatform :: Platform , _rVersion :: Maybe Versioning } deriving (Eq, Show) type PlatformVersionSpec = Map (Maybe Versioning) DownloadInfo type PlatformSpec = Map Platform PlatformVersionSpec type ArchitectureSpec = Map Architecture PlatformSpec type ToolVersionSpec = Map Version VersionInfo type BinaryDownloads = Map Tool ToolVersionSpec type SourceDownloads = Map Version DownloadInfo data GHCupDownloads = GHCupDownloads { _binaryDownloads :: BinaryDownloads , _sourceDownloads :: SourceDownloads } deriving Show data URLSource = GHCupURL | OwnSource URI | OwnSpec GHCupDownloads deriving Show