ghcup-hs/lib/GHCup/Types.hs

126 lines
2.9 KiB
Haskell
Raw Normal View History

2020-01-14 21:55:34 +00:00
{-# LANGUAGE DeriveGeneric #-}
module GHCup.Types where
2020-01-16 22:27:38 +00:00
import Data.Map.Strict ( Map )
2020-03-03 00:59:19 +00:00
import Data.Text ( Text )
2020-01-16 22:27:38 +00:00
import Data.Versions
2020-03-01 00:05:02 +00:00
import HPath
2020-02-19 19:54:23 +00:00
import URI.ByteString
2020-01-14 21:55:34 +00:00
2020-03-01 00:05:02 +00:00
import qualified GHC.Generics as GHC
2020-01-14 21:55:34 +00:00
2020-03-03 00:59:19 +00:00
data Settings = Settings
{ cache :: Bool
, urlSource :: URLSource
}
deriving Show
2020-02-29 23:07:39 +00:00
data DebugInfo = DebugInfo
{ diBaseDir :: Path Abs
, diBinDir :: Path Abs
, diGHCDir :: Path Abs
, diCacheDir :: Path Abs
, diURLSource :: URLSource
, diArch :: Architecture
, diPlatform :: PlatformResult
}
deriving Show
2020-02-24 13:56:13 +00:00
data SetGHC = SetGHCOnly -- ^ unversioned 'ghc'
| SetGHCMajor -- ^ ghc-x.y
2020-02-29 23:07:39 +00:00
| SetGHCMinor -- ^ ghc-x.y.z -- TODO: rename
2020-03-03 00:59:19 +00:00
deriving (Eq, Show)
2020-02-24 13:56:13 +00:00
2020-02-22 18:21:10 +00:00
data Tag = Latest
| Recommended
2020-02-28 23:33:32 +00:00
deriving (Ord, Eq, Show)
2020-02-22 18:21:10 +00:00
2020-02-24 13:56:13 +00:00
data VersionInfo = VersionInfo
{ _viTags :: [Tag]
2020-02-22 18:21:10 +00:00
, _viArch :: ArchitectureSpec
2020-02-24 13:56:13 +00:00
}
deriving (Eq, Show)
2020-02-22 18:21:10 +00:00
2020-02-24 13:56:13 +00:00
data DownloadInfo = DownloadInfo
{ _dlUri :: URI
2020-02-22 18:21:10 +00:00
, _dlSubdir :: Maybe (Path Rel)
2020-03-03 00:59:19 +00:00
, _dlHash :: Text
2020-02-24 13:56:13 +00:00
}
deriving (Eq, Show)
2020-02-22 18:21:10 +00:00
2020-01-14 21:55:34 +00:00
data Tool = GHC
2020-03-03 00:59:19 +00:00
| GHCSrc
2020-01-14 21:55:34 +00:00
| Cabal
2020-03-03 22:34:25 +00:00
| GHCup
2020-01-17 00:48:42 +00:00
deriving (Eq, GHC.Generic, Ord, Show)
2020-01-14 21:55:34 +00:00
2020-02-24 13:56:13 +00:00
data ToolRequest = ToolRequest
2020-03-03 00:59:19 +00:00
{ _trTool :: Tool
2020-02-29 23:07:39 +00:00
, _trVersion :: Version
2020-02-24 13:56:13 +00:00
}
deriving (Eq, Show)
2020-01-16 22:27:38 +00:00
2020-01-14 21:55:34 +00:00
data Architecture = A_64
| A_32
2020-01-17 00:48:42 +00:00
deriving (Eq, GHC.Generic, Ord, Show)
2020-01-14 21:55:34 +00:00
2020-01-16 22:27:38 +00:00
data LinuxDistro = Debian
| Ubuntu
| Mint
| Fedora
| CentOS
| RedHat
| Alpine
-- rolling
| Gentoo
| Exherbo
2020-01-14 21:55:34 +00:00
-- not known
| UnknownLinux
-- ^ must exit
deriving (Eq, GHC.Generic, Ord, Show)
data Platform = Linux LinuxDistro
-- ^ must exit
| Darwin
-- ^ must exit
2020-01-16 22:27:38 +00:00
| FreeBSD
2020-01-14 21:55:34 +00:00
deriving (Eq, GHC.Generic, Ord, Show)
2020-02-24 13:56:13 +00:00
data PlatformResult = PlatformResult
{ _platform :: Platform
2020-01-16 22:27:38 +00:00
, _distroVersion :: Maybe Versioning
2020-02-24 13:56:13 +00:00
}
deriving (Eq, Show)
2020-01-16 22:27:38 +00:00
2020-02-24 13:56:13 +00:00
data PlatformRequest = PlatformRequest
{ _rArch :: Architecture
2020-01-16 22:27:38 +00:00
, _rPlatform :: Platform
2020-02-24 13:56:13 +00:00
, _rVersion :: Maybe Versioning
}
deriving (Eq, Show)
2020-01-16 22:27:38 +00:00
2020-02-22 18:21:10 +00:00
type PlatformVersionSpec = Map (Maybe Versioning) DownloadInfo
2020-01-16 22:27:38 +00:00
type PlatformSpec = Map Platform PlatformVersionSpec
2020-01-14 21:55:34 +00:00
type ArchitectureSpec = Map Architecture PlatformSpec
2020-02-22 18:21:10 +00:00
type ToolVersionSpec = Map Version VersionInfo
2020-03-03 00:59:19 +00:00
type BinaryDownloads = Map Tool ToolVersionSpec
type SourceDownloads = Map Version DownloadInfo
2020-01-16 22:27:38 +00:00
2020-03-03 00:59:19 +00:00
data GHCupDownloads = GHCupDownloads {
_binaryDownloads :: BinaryDownloads
, _sourceDownloads :: SourceDownloads
} deriving Show
2020-01-14 21:55:34 +00:00
2020-01-16 22:27:38 +00:00
data URLSource = GHCupURL
2020-02-19 19:54:23 +00:00
| OwnSource URI
2020-03-03 00:59:19 +00:00
| OwnSpec GHCupDownloads
2020-02-22 18:21:10 +00:00
deriving Show
2020-03-03 00:59:19 +00:00