Skip to content

Commit

Permalink
Remove OtherLinux
Browse files Browse the repository at this point in the history
Since we now have permissive parsing anyway.
  • Loading branch information
hasufell committed Nov 20, 2024
1 parent 6afbc4f commit 3653066
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/GHCup/Platform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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|\>|])
Expand Down
4 changes: 0 additions & 4 deletions lib/GHCup/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/GHCup/Types/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down
5 changes: 2 additions & 3 deletions test/ghcup-test/GHCup/ArbitraryTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3653066

Please sign in to comment.