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

Allow changing the root directory for resolving imports #54

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

TimWSpence
Copy link
Collaborator

We can now do
Resolver.resolve(expr)
or
Resolver.resolveRelativeTo(Paths.get("/tmp"))(expr)

We can now do
`Resolver.resolve(expr)`
or
`Resolver.resolveRelativeTo(Paths.get("/tmp"))(expr)`
//We add a placeholder filename "package.dhall" for the base directory as a Local import must have a filename
new ResolveImportsVisitor(semanticCache,
semiSemanticCache,
NonEmptyList.one(Local(relativeTo.resolve("package.dhall"))))
Copy link
Owner

Choose a reason for hiding this comment

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

I'll try it out tomorrow, but this will do the right thing if relativeTo is a file, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh good question! The intention was definitely that it be a directory. I suspect it might not work. Will have a think about that one

Copy link
Owner

@travisbrown travisbrown left a comment

Choose a reason for hiding this comment

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

👍, looks good to me, thanks! I'll merge in the morning.

result <- if (mode == ImportMode.LOCATION) importLocation(imp) else importNonLocation(imp, mode, hash)
} yield result
}
}

private object ResolveImportsVisitor {
def apply[F[_] <: AnyRef: Sync: Client]: F[ResolveImportsVisitor[F]] =
Sync[F].map2(ImportCache[F]("dhall"), ImportCache[F]("dhallj"))(apply[F](_, _))
def apply[F[_] <: AnyRef: Sync: Client](relativeTo: Path): F[ResolveImportsVisitor[F]] =
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about keeping around the old method signatures as well, using cwd as above? MiMa doesn't like the missing applys, even though this is a private object. Then we could remove them in 0.3.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.

Oh wow. I didn't think it would care about a private object. Yeah, that's fine by me

@travisbrown travisbrown merged commit 3f554bc into master Apr 22, 2020
@travisbrown travisbrown deleted the root-directory-for-imports branch April 22, 2020 11:02
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