Skip to content
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

Add freeze command #486

Merged
merged 6 commits into from
Jun 26, 2018
Merged

Add freeze command #486

merged 6 commits into from
Jun 26, 2018

Conversation

gilligan
Copy link
Collaborator

This PR adds a freeze command as described in #437

Given

    let replicate =
          https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate

in  replicate 5

the freeze command will produce:

    let replicate =
          https://raw.githubusercontent.com/dhall-lang/Prelude/c79c2bc3c46f129cc5b6d594ce298a381bcae92c/List/replicate sha256:b0e3ec1797b32c80c0bcb7e8254b08c7e9e35e75e6b410c7ac21477ab90167ad 

in  replicate 5

The PR doesn't include tests or updates to Tutorial.hs - can those be done separately or should those be included to make this eligible for merge?

Thanks to @Gabriel439 and @ocharles for the help on this.

@gilligan gilligan changed the title Add freeze Add freeze command Jun 25, 2018
Copy link
Collaborator

@Gabriella439 Gabriella439 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are not required but I would like to see a Tutorial section addition. Even just turning your pull request description into a new tutorial section would be good enough

@@ -139,6 +142,19 @@ parseMode =
parserWithHelper = Options.Applicative.helper <*> parser
parser = Format <$> optional parseInplace

freezeSubcommand =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify this as:

freezeSubcommand = subcommand "freeze" "Add hashes to all import statements of an expression" parseFreeze
  where
    parseFreeze = Freeze <$> optional parseInplace

where
fromStdin = System.IO.hSetEncoding System.IO.stdin System.IO.utf8 >> Data.Text.IO.getContents

hashImport :: Import -> IO Import
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also export this utility since it is handy for people using the Haskell API

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@gilligan
Copy link
Collaborator Author

Added a paragraph on freeze to the Tutorial, please take a look.

Copy link
Collaborator

@Gabriella439 Gabriella439 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor suggestions

I also added you as a contributor so you can merge at any time

--
-- If you have a file which either doesn't already use hashed imports,
-- or you changed some of the imports and want to update the hashes you can use the
-- freeze command to either add or updated hashes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/updated/update/

--
-- > cat foo.dhall
-- ''
-- let replicate = ./r.dhall
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use the GitHub URL for the import so that users can reproduce the example and also so that I can later add the example to the test suite

Tobias Pflug added 6 commits June 26, 2018 19:04
The freeze command ..

- takes input from stdin or file
- traverses the Expression adding hashes to imports
- writes result to stdout or file
@gilligan gilligan merged commit dba035e into dhall-lang:master Jun 26, 2018
@gilligan gilligan deleted the add-freeze branch June 26, 2018 17:30
@f-f f-f mentioned this pull request Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants