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 importing modules as raw YAML #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

cowboyd
Copy link
Member

@cowboyd cowboyd commented Feb 14, 2023

Motivation

See #79 for context

Approach

This implements the $import { location: string, quote: true } syntax described in the above issue. To do it, a new value type PSQuote is introduce which can contain any other PSValue. A PSQuote evaluates to the value it quotes. In this way it "shields" the value from evaluation, so rather than traversing the tree to evaluate it, the tree itself is returned.

When an import is marked as quote, the resulting module value is quoted.

Alternate Designs

For marking quotes:

  • We could add a quoted property to every PSValue rather than decorating it. I decided against this for two reasons:
    1. It was unclear to me how this would work when we added quasi quote and unquote
    2. we could switch on the node type rather than have if statements everywhere to find out if this was a quoted string or a unquoted string.

For marking that an import is to be quoted:

I wasn't super thrilled about map specifier for modules:

$import:
  symbol:
     location: module/path.yaml
     quote: true

But a better alternative that didn't bring in more complexity did not present itself. We may want to use tags in some form or another later on and deprecate this syntax.

Implement the quote system for imports documented in
#79
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.

1 participant