diff --git a/lib/GHCup/Platform.hs b/lib/GHCup/Platform.hs index 93dcd05d..efd92db4 100644 --- a/lib/GHCup/Platform.hs +++ b/lib/GHCup/Platform.hs @@ -158,7 +158,7 @@ getLinuxDistro = do | hasWord ["rocky", "Rocky Linux"] -> Rocky -- https://github.com/void-linux/void-packages/blob/master/srcpkgs/base-files/files/os-release | hasWord ["void", "Void Linux"] -> Void - | otherwise -> OtherLinux (T.unpack $ fromMaybe name mid) + | otherwise -> UnknownLinux pure (distro, parsedVer) where regex x = makeRegexOpts compIgnoreCase execBlank ([s|\<|] ++ x ++ [s|\>|]) diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index 5e989c20..06b6be41 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -258,8 +258,6 @@ data LinuxDistro = Debian | OpenSUSE -- not known | UnknownLinux - -- ^ must exit - | OtherLinux String deriving (Eq, GHC.Generic, Ord, Show) instance Enum LinuxDistro where @@ -293,7 +291,6 @@ instance Enum LinuxDistro where fromEnum Exherbo = 11 fromEnum OpenSUSE = 12 fromEnum UnknownLinux = 13 - fromEnum (OtherLinux _) = error "fromEnum: OtherLinux" instance Bounded LinuxDistro where minBound = Debian @@ -319,7 +316,6 @@ distroToString Gentoo = "gentoo" distroToString Exherbo = "exherbo" distroToString OpenSUSE = "opensuse" distroToString UnknownLinux = "unknown" -distroToString (OtherLinux str) = str instance Pretty LinuxDistro where pPrint = text . distroToString diff --git a/lib/GHCup/Types/JSON.hs b/lib/GHCup/Types/JSON.hs index 07126634..a4a3c941 100644 --- a/lib/GHCup/Types/JSON.hs +++ b/lib/GHCup/Types/JSON.hs @@ -50,7 +50,6 @@ import qualified Text.Megaparsec as MP import qualified Text.Megaparsec.Char as MPC instance ToJSON LinuxDistro where - toJSON (OtherLinux x) = String (T.pack x) toJSON x = String . T.pack . show $ x instance FromJSON LinuxDistro where @@ -69,7 +68,7 @@ instance FromJSON LinuxDistro where "exherbo" -> pure Exherbo "opensuse" -> pure OpenSUSE "unknownlinux" -> pure UnknownLinux - _ -> pure (OtherLinux $ T.unpack t) + _ -> fail "Unknown Linux distro" deriveJSON defaultOptions { fieldLabelModifier = removeLensFieldLabel } ''MetaMode deriveJSON defaultOptions { fieldLabelModifier = removeLensFieldLabel } ''Architecture @@ -142,7 +141,6 @@ instance ToJSONKey Platform where toJSONKey = toJSONKeyText $ \case Darwin -> T.pack "Darwin" FreeBSD -> T.pack "FreeBSD" - Linux (OtherLinux s) -> T.pack ("Linux_" <> s) Linux d -> T.pack ("Linux_" <> show d) Windows -> T.pack "Windows" diff --git a/test/ghcup-test/GHCup/ArbitraryTypes.hs b/test/ghcup-test/GHCup/ArbitraryTypes.hs index 916add68..44f8d5f9 100644 --- a/test/ghcup-test/GHCup/ArbitraryTypes.hs +++ b/test/ghcup-test/GHCup/ArbitraryTypes.hs @@ -136,9 +136,8 @@ instance Arbitrary DownloadInfo where shrink = genericShrink instance Arbitrary LinuxDistro where - arbitrary = do - let other = OtherLinux <$> listOf (elements ['a' .. 'z']) - oneof (other:(pure <$> allDistros)) + arbitrary = + oneof (pure <$> allDistros) instance Arbitrary Platform where arbitrary = genericArbitrary