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

Fix import logic with --file for dhall-to-{json,yaml} #1191

Merged
merged 1 commit into from
Aug 3, 2019

Conversation

sjakobi
Copy link
Collaborator

@sjakobi sjakobi commented Aug 2, 2019

Fixes #1183.

@@ -951,13 +953,18 @@ handleSpecialDoubles specialDoubleMode =
codeToValue
:: Conversion
-> SpecialDoubleMode
-> Text -- ^ Describe the input for the sake of error location.
-> Maybe FilePath -- ^ The source file path. If no path is given, imports
-- are resolved relative to the current directory.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@deepfire You introduced the Text input description in dhall-lang/dhall-json#20. Is this change ok for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, this change is fine


-- | Resolve all imports within an expression, importing relative to the given
-- directory.
loadWithDir :: FilePath -> Expr Src Import -> IO (Expr Src X)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would loadWithRootDirectory be a better name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe loadRelativeTo?

resolvedExpression <- Dhall.Import.load parsedExpression
let rootDirectory = case mFilePath of
Nothing -> "."
Just fp -> System.FilePath.takeDirectory fp
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that I didn't adopt dhall's way of interpreting --file - as stdin here, as I think it's a bit redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we should probably change dhall to match, for consistency


-- | Resolve all imports within an expression, importing relative to the given
-- directory.
loadWithDir :: FilePath -> Expr Src Import -> IO (Expr Src X)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe loadRelativeTo?

@@ -951,13 +953,18 @@ handleSpecialDoubles specialDoubleMode =
codeToValue
:: Conversion
-> SpecialDoubleMode
-> Text -- ^ Describe the input for the sake of error location.
-> Maybe FilePath -- ^ The source file path. If no path is given, imports
-- are resolved relative to the current directory.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, this change is fine

resolvedExpression <- Dhall.Import.load parsedExpression
let rootDirectory = case mFilePath of
Nothing -> "."
Just fp -> System.FilePath.takeDirectory fp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Then we should probably change dhall to match, for consistency

@sjakobi
Copy link
Collaborator Author

sjakobi commented Aug 3, 2019

AppVeyor fails due to

Uploading artifacts...
Maximum allowed artifact storage size of 50000 Mb will be exceeded.

I'd suggest clearing the cache, but this might be about the artifact deployment to GitHub?!

@Gabriella439
Copy link
Collaborator

@mergify mergify bot merged commit 1700fa7 into master Aug 3, 2019
@mergify mergify bot deleted the sjakobi/1183-file-option branch August 3, 2019 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--file resolves paths differently between dhall and dhall-to-yaml
2 participants