ghcup-hs/lib/GHCup/Types.hs

94 lines
2.2 KiB
Haskell
Raw Normal View History

2020-01-14 21:55:34 +00:00
{-# LANGUAGE DeriveGeneric #-}
module GHCup.Types where
2020-02-22 18:21:10 +00:00
import HPath
2020-01-16 22:27:38 +00:00
import Data.Map.Strict ( Map )
import qualified GHC.Generics as GHC
import Data.Versions
2020-02-19 19:54:23 +00:00
import URI.ByteString
2020-01-14 21:55:34 +00:00
2020-02-24 13:56:13 +00:00
data SetGHC = SetGHCOnly -- ^ unversioned 'ghc'
| SetGHCMajor -- ^ ghc-x.y
| SetGHCMinor -- ^ ghc-x.y.z
deriving Show
2020-02-22 18:21:10 +00:00
data Tag = Latest
| Recommended
deriving (Eq, Show)
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-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
| Cabal
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
{ _tool :: Tool
2020-01-16 22:27:38 +00:00
, _toolVersion :: 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-01-16 22:27:38 +00:00
type AvailableDownloads = Map Tool ToolVersionSpec
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-01-16 22:27:38 +00:00
| OwnSpec AvailableDownloads
2020-02-22 18:21:10 +00:00
deriving Show