Skip to content

Commit 72315e0

Browse files
authored
Backport some fixes from compiling with GHC 8.10 (#748)
1 parent ff91075 commit 72315e0

File tree

7 files changed

+11
-21
lines changed

7 files changed

+11
-21
lines changed

src/Spago/Command/Ls.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ formatPackageNames = \case
6565
formatPackageNamesJson :: [(PackageName, Package)] -> [Text]
6666
formatPackageNamesJson pkgs =
6767
let
68-
asJson (PackageName{..}, Package{ location = loc@Remote{..}, ..})
68+
asJson (PackageName{..}, Package{ location = loc@Remote{..} })
6969
= JsonPackageOutput
7070
{ json_packageName = packageName
7171
, json_repo = toJSON loc
7272
, json_version = version
7373
}
74-
asJson (PackageName{..}, Package { location = loc@Local{..}, ..})
74+
asJson (PackageName{..}, Package { location = loc@(Local _), ..})
7575
= JsonPackageOutput
7676
{ json_packageName = packageName
7777
, json_repo = toJSON loc

src/Spago/Config.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ parsePackage (Dhall.RecordLit ks') = do
7171
let location = Remote{..}
7272
pure Package{..}
7373
parsePackage (Dhall.App
74-
(Dhall.Field union (Dhall.FieldSelection { fieldSelectionLabel = "Local", ..}))
74+
(Dhall.Field union (Dhall.FieldSelection { fieldSelectionLabel = "Local" }))
7575
(Dhall.TextLit (Dhall.Chunks [] spagoConfigPath)))
7676
| isLocationType union = do
7777
localPath <- case Text.isSuffixOf "/spago.dhall" spagoConfigPath of
@@ -272,7 +272,7 @@ migrateBower Bower.PackageMeta{..} PackageSet{..} = (packageName, dependencies)
272272
Nothing -> Left $ NonPureScript name
273273
Just packageSetName | package <- PackageName packageSetName -> case Map.lookup package packagesDB of
274274
Nothing -> Left $ MissingFromTheSet package
275-
Just Package{ location = Local {..} } -> Right package
275+
Just Package{ location = Local _ } -> Right package
276276
Just Package{ location = Remote {..} } -> case SemVer.parseSemVer version of
277277
Right v | SemVer.matches range v -> Right package
278278
_ -> Left $ WrongVersion package range version

src/Spago/FetchPackage.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ fetchPackage
9696
. (HasLogFunc env, HasGlobalCache env)
9797
=> GlobalCache.ReposMetadataV1 -> (PackageName, Package)
9898
-> RIO env ()
99-
fetchPackage _ (PackageName package, Package { location = Local{..}, .. }) =
99+
fetchPackage _ (PackageName package, Package { location = Local{..} }) =
100100
logInfo $ display $ Messages.foundLocalPackage package localPath
101-
fetchPackage metadata pair@(packageName'@PackageName{..}, Package{ location = Remote{..}, .. } ) = do
101+
fetchPackage metadata pair@(packageName'@PackageName{..}, Package{ location = Remote{..} } ) = do
102102
logDebug $ "Fetching package " <> display packageName
103103
GlobalCache globalCacheDir cacheFlag <- view (the @GlobalCache)
104104
let useGlobalCache = cacheFlag /= Just SkipCache
@@ -194,9 +194,9 @@ getPackageDir PackageName{..} version = Text.unpack packageName <> "/" <> Text.u
194194
-- If the package is from a remote git repo, return the folder inside the local cache
195195
-- Otherwise return the local folder
196196
getLocalCacheDir :: (PackageName, Package) -> FilePath.FilePath
197-
getLocalCacheDir (packageName, Package{ location = Remote{..}, .. }) = do
197+
getLocalCacheDir (packageName, Package{ location = Remote{..} }) = do
198198
localCacheDir <> "/" <> getPackageDir packageName version
199-
getLocalCacheDir (_, Package{ location = Local{..}, .. }) =
199+
getLocalCacheDir (_, Package{ location = Local{..} }) =
200200
Text.unpack localPath
201201

202202

src/Spago/PackageSet.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,8 @@ updatePackageSetVersion maybeTag = do
158158
, directory = Dhall.Directory
159159
{ components = [ currentTag, "download", "releases", repo, org ]}
160160
}
161-
, ..
162161
}
163-
, ..
164162
}
165-
, ..
166163
} = [(org, repo, currentTag)]
167164
getCurrentTag _ = []
168165

@@ -177,11 +174,9 @@ updatePackageSetVersion maybeTag = do
177174
{ file = "packages.dhall"
178175
, directory = Dhall.Directory
179176
{ components = [ _currentTag, "download", "releases", upgradeRepo, upgradeOrg ]}
180-
, ..
181177
}
182178
, ..
183179
}
184-
, ..
185180
}
186181
, ..
187182
}) | upgradeRepo == repo && upgradeOrg == org =
@@ -234,9 +229,7 @@ isRemoteFrozen (Dhall.Import
234229
{ importHashed = Dhall.ImportHashed
235230
{ importType = Dhall.Remote _
236231
, hash
237-
, ..
238232
}
239-
, ..
240233
}) = [isJust hash]
241234
isRemoteFrozen _ = []
242235

src/Spago/Purs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ docs format sourcePaths = do
104104
pursVersion :: RIO env (Either Text Version.SemVer)
105105
pursVersion = Turtle.Bytes.shellStrictWithErr (purs <> " --version") empty >>= \case
106106
(ExitSuccess, out, _err) -> do
107-
let versionText = headMay $ Text.split (== ' ') (Text.Encoding.decodeUtf8With lenientDecode out)
107+
let versionText = headMay $ Text.split (== ' ') (Text.strip $ Text.Encoding.decodeUtf8With lenientDecode out)
108108
parsed = versionText >>= (hush . Version.semver)
109109

110110
pure $ case parsed of

test/BumpVersionSpec.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedLists #-}
12
module BumpVersionSpec (spec) where
23

34
import Data.Versions (SemVer (..), VUnit (..))

test/SpagoSpec.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import qualified Data.Text as Text
55
import Prelude hiding (FilePath)
66
import qualified System.IO.Temp as Temp
77
import Test.Hspec (Spec, around_, describe, it, shouldBe, shouldNotSatisfy,
8-
shouldReturn, shouldSatisfy)
8+
shouldNotBe, shouldReturn, shouldSatisfy)
99
import Turtle (ExitCode (..), cd, cp, decodeString, empty, encodeString,
1010
mkdir, mktree, mv, pwd, readTextFile, rm, shell,
1111
shellStrictWithErr, testdir, writeTextFile, (</>))
@@ -607,9 +607,6 @@ spec = around_ setup $ do
607607
newPackages <- Text.strip <$> readTextFile "packages.dhall"
608608
newPackages `shouldBe` packageSetUrl
609609

610-
{-
611-
-- Note: this is commented because of https://github.com/purescript/spago/issues/685#issuecomment-694342262
612-
613610
it "Spago should migrate a package set from an alternative repository from src/packages.dhall" $ do
614611

615612
spago ["init"] >>= shouldBeSuccess
@@ -618,7 +615,6 @@ spec = around_ setup $ do
618615
newPackages <- Text.strip <$> readTextFile "packages.dhall"
619616
newPackages `shouldNotBe` "https://github.com/purerl/package-sets/releases/download/erl-0.13.6-20200713/packages.dhall"
620617
newPackages `shouldSatisfy` Text.isPrefixOf "https://github.com/purerl/package-sets/releases/download"
621-
-}
622618

623619
it "Spago should migrate package-set from src/packages.dhall to the user-specified one if it exists" $ do
624620
-- initialize the project, so that it uses latest package set release

0 commit comments

Comments
 (0)