Skip to content

Fix dhall freeze --cache to support v21.0.0 #2350

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

Merged
merged 3 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dhall/src/Dhall/Freeze.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ freezeExpression
-> IO (Expr s Import)
freezeExpression = freezeExpressionWithManager Dhall.Import.defaultNewManager

-- https://github.com/dhall-lang/dhall-haskell/issues/2347
toMissing :: Import -> Import
toMissing import_ =
import_ { importHashed = (importHashed import_) { importType = Missing } }


-- | See 'freezeExpression'.
freezeExpressionWithManager
:: IO Dhall.Import.Manager
Expand Down Expand Up @@ -315,17 +321,21 @@ freezeExpressionWithManager newManager directory scope intent expression = do
(Embed import_@(Import { importHashed = ImportHashed { hash = Nothing } })) = do
frozenImport <- freezeFunction import_

let frozenMissing = toMissing frozenImport

{- The two imports can be the same if the import is local and
`freezeFunction` only freezes remote imports by default
-}
if frozenImport /= import_
then return (ImportAlt (Embed frozenImport) (Embed import_))
then return (ImportAlt (Embed frozenMissing) (Embed import_))
else return (Embed import_)
cache
(Embed import_@(Import { importHashed = ImportHashed { hash = Just _ } })) = do
-- Regenerate the integrity check, just in case it's wrong
frozenImport <- freezeFunction import_

let frozenMissing = toMissing frozenImport

-- `dhall freeze --cache` also works the other way around, adding an
-- unprotected fallback import to imports that are already
-- protected
Expand All @@ -335,7 +345,7 @@ freezeExpressionWithManager newManager directory scope intent expression = do
}
}

return (ImportAlt (Embed frozenImport) (Embed thawedImport))
return (ImportAlt (Embed frozenMissing) (Embed thawedImport))
cache expression_ =
return expression_

Expand Down
2 changes: 1 addition & 1 deletion dhall/tests/freeze/cachedB.dhall
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./True.dhall
missing
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
2 changes: 1 addition & 1 deletion dhall/tests/freeze/incorrectHashB.dhall
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./True.dhall
missing
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
2 changes: 1 addition & 1 deletion dhall/tests/freeze/protectedB.dhall
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./True.dhall
missing
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
2 changes: 1 addition & 1 deletion dhall/tests/freeze/unprotectedB.dhall
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./True.dhall
missing
sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
? ./True.dhall
4 changes: 4 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ nix:
packages:
- ncurses
- zlib
flags:
# https://github.com/RyanGlScott/mintty/issues/4
mintty:
Win32-2-13-1: false