-
Notifications
You must be signed in to change notification settings - Fork 209
Clean up warnings #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Clean up warnings #1444
Changes from all commits
230d9a5
0e337d9
df5f866
5bcd977
7cddcf5
3282892
880dc82
80613cf
baf8a06
4de722a
56ed0ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -763,7 +763,8 @@ coreFeature ServerEnv{serverBlobStore = store} UserFeature{..} | |
|
|
||
| serveCabalFileRevisionName :: DynamicPath -> ServerPartE Response | ||
| serveCabalFileRevisionName dpath = do | ||
| pkgid1 <- packageTarballInPath dpath | ||
| -- TODO bug? Maybe something to do with #1439 | ||
| _pkgid1 <- packageTarballInPath dpath | ||
| pkgid2 <- packageInPath dpath | ||
| guard (pkgVersion pkgid2 == pkgVersion pkgid2) | ||
|
Comment on lines
+766
to
769
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the sort of bogus code warnings are supposed to catch. I haven't yet learned enough to understand what is going on here, but surely it can't be right to compare |
||
| pkginfo <- packageInPath dpath >>= lookupPackageId | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,9 +176,9 @@ updateHistory (InMemStats day perPkg) (OnDiskStats (NCM _ m)) = | |
| updatesMap :: Map.Map PackageName OnDiskPerPkg | ||
| updatesMap = Map.fromList | ||
| [ (pkgname, applyUpdates pkgs) | ||
| | pkgs <- groupBy ((==) `on` (packageName . fst)) | ||
| (cmToList perPkg :: [(PackageId, Int)]) | ||
| , let pkgname = packageName (fst (head pkgs)) | ||
| | pkgs@((pkgId, _):_) <- groupBy ((==) `on` (packageName . fst)) | ||
| (cmToList perPkg :: [(PackageId, Int)]) | ||
| , let pkgname = packageName pkgId | ||
|
Comment on lines
-179
to
+181
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this is a list comprehension, a failing pattern will cause the element to be skipped. Previously, it would have been a crash. See my other comment for my reasoning of why crashes are better than incorrect results. So I don't think we should do this right now in this PR.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, we're leaning on the guarantee that the sublists returned by There's the alternative approach of using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems like it would be better since it has a more exact type! |
||
| ] | ||
|
|
||
| applyUpdates :: [(PackageId, Int)] -> OnDiskPerPkg | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,6 @@ instance ToSElem Change where | |
| where | ||
| -- TODO/FIXME: stringly hack | ||
| what = case what0 of | ||
| ('a':'d':'d':'e':'d':_) -> 'A' : tail what0 | ||
| ('r':'e':'m':'o':'v':'e':'d':_) -> 'R' : tail what0 | ||
| _ -> "Changed " ++ what0 | ||
| ('a':what1@('d':'d':'e':'d':_)) -> 'A' : what1 | ||
| ('r':what1@('e':'m':'o':'v':'e':'d':_)) -> 'R' : what1 | ||
| _ -> "Changed " ++ what0 | ||
|
Comment on lines
+171
to
+173
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one I like, as readability is hardly impaired. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,12 +304,12 @@ candidatesFeature ServerEnv{serverBlobStore = store} | |
| where | ||
| cpiToJSON :: [CandPkgInfo] -> Value | ||
| cpiToJSON [] = Null -- should never happen | ||
| cpiToJSON pkgs = object | ||
| cpiToJSON pkgs@(pkg:_) = object | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is good! It makes the function total, the type system recognizes the complete pattern match, and readability is not impaired. |
||
| [ Key.fromString "name" .= pn | ||
| , Key.fromString "candidates" .= pvs | ||
| ] | ||
| where | ||
| pn = T.pack . display . pkgName . candInfoId . head $ pkgs | ||
| pn = T.pack . display . pkgName . candInfoId $ pkg | ||
| pvs = [ object [ Key.fromString "version" .= (T.pack . display . packageVersion . candInfoId) p | ||
| , Key.fromString "sha256" .= (blobInfoHashSHA256 . pkgTarballGz . fst) tarball | ||
| ] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is an improvement, since the algorithm now runs further if the
_assumedZeroisn't actually zero. But should it run further? It's basically the question of whether you wantasserts in prod or not.Personally, I think partiality is better than an incorrect result. Even though the compiler warns for partiality, but it doesn't warn for incorrectness. Of course, it would be even better to prove the algorithm correct. But that isn't always feasible, and the lack of dependent types make it extra difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. How about:
caseerrorin the non-zero lower bound case (with a description of the violated invariant)HasCallStackconstraint