Skip to content

Commit

Permalink
Improve parsing of --platform values, fixes #1057
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed May 3, 2024
1 parent ea964ee commit 6c59475
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib-opt/GHCup/OptParse/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ platformParser s' = case MP.parse (platformP <* MP.eof) "" (T.pack s') of
Left e -> Left $ errorBundlePretty e
where
archP :: MP.Parsec Void Text Architecture
archP = MP.try (MP.chunk "x86_64" $> A_64) <|> (MP.chunk "i386" $> A_32)
archP = choice' ((\x -> MP.chunk (T.pack $ archToString x) $> x) <$> ([minBound..maxBound] :: [Architecture]))
platformP :: MP.Parsec Void Text PlatformRequest
platformP = choice'
[ (`PlatformRequest` FreeBSD)
Expand All @@ -208,6 +208,9 @@ platformParser s' = case MP.parse (platformP <* MP.eof) "" (T.pack s') of
)
<* MP.chunk "-linux"
)
, (\a -> PlatformRequest a Windows Nothing)
<$> ((archP <* MP.chunk "-")
<* (MP.chunk "unknown-mingw32" <|> MP.chunk "unknown-windows" <|> MP.chunk "windows"))
]
distroP :: MP.Parsec Void Text LinuxDistro
distroP = choice' ((\d -> MP.chunk (T.pack $ distroToString d) $> d) <$> allDistros)
Expand Down
2 changes: 1 addition & 1 deletion lib/GHCup/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ data Architecture = A_64
| A_Sparc64
| A_ARM
| A_ARM64
deriving (Eq, GHC.Generic, Ord, Show)
deriving (Eq, GHC.Generic, Ord, Show, Bounded, Enum)

instance NFData Architecture

Expand Down

0 comments on commit 6c59475

Please sign in to comment.