mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-30 04:40:24 +01:00
Ghc major version whitelist is now drawn from stackage-content
This commit is contained in:
parent
8a3f199ebb
commit
90ad3afe19
@ -6,6 +6,7 @@ module Data.GhcLinks
|
|||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
import Control.Monad.State.Strict (modify, execStateT)
|
import Control.Monad.State.Strict (modify, execStateT)
|
||||||
import qualified Data.HashMap.Strict as HashMap
|
import qualified Data.HashMap.Strict as HashMap
|
||||||
|
import qualified Data.Yaml as Yaml
|
||||||
import Filesystem (readTextFile, isFile)
|
import Filesystem (readTextFile, isFile)
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
@ -18,24 +19,24 @@ newtype GhcLinks = GhcLinks
|
|||||||
supportedArches :: [SupportedArch]
|
supportedArches :: [SupportedArch]
|
||||||
supportedArches = [minBound .. maxBound]
|
supportedArches = [minBound .. maxBound]
|
||||||
|
|
||||||
supportedGhcMajorVersions :: [GhcMajorVersion]
|
|
||||||
supportedGhcMajorVersions = ["7.8", "7.10"]
|
|
||||||
|
|
||||||
|
|
||||||
readGhcLinks :: FilePath -> IO GhcLinks
|
readGhcLinks :: FilePath -> IO GhcLinks
|
||||||
readGhcLinks dir = do
|
readGhcLinks dir = do
|
||||||
let opts =
|
let ghcMajorVersionsPath = dir </> "supported-ghc-major-versions.yaml"
|
||||||
[ (arch, ver)
|
Yaml.decodeFile (fpToString ghcMajorVersionsPath) >>= \case
|
||||||
| arch <- supportedArches
|
Nothing -> return $ GhcLinks HashMap.empty
|
||||||
, ver <- supportedGhcMajorVersions
|
Just (ghcMajorVersions :: [GhcMajorVersion]) -> do
|
||||||
]
|
let opts =
|
||||||
hashMap <- flip execStateT HashMap.empty
|
[ (arch, ver)
|
||||||
$ forM_ opts $ \(arch, ver) -> do
|
| arch <- supportedArches
|
||||||
let fileName = "ghc-" <> ver <> "-links.yaml"
|
, ver <- ghcMajorVersions
|
||||||
let path = dir
|
]
|
||||||
</> fpFromText (toPathPiece arch)
|
hashMap <- flip execStateT HashMap.empty
|
||||||
</> fpFromText fileName
|
$ forM_ opts $ \(arch, ver) -> do
|
||||||
whenM (liftIO $ isFile path) $ do
|
let fileName = "ghc-" <> ver <> "-links.yaml"
|
||||||
text <- liftIO $ readTextFile path
|
let path = dir
|
||||||
modify (HashMap.insert (arch, ver) text)
|
</> fpFromText (toPathPiece arch)
|
||||||
return $ GhcLinks hashMap
|
</> fpFromText fileName
|
||||||
|
whenM (liftIO $ isFile path) $ do
|
||||||
|
text <- liftIO $ readTextFile path
|
||||||
|
modify (HashMap.insert (arch, ver) text)
|
||||||
|
return $ GhcLinks hashMap
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user