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 new dhall to-directory-tree command #1606

Merged
merged 5 commits into from
Dec 14, 2019
Merged

Add new dhall to-directory-tree command #1606

merged 5 commits into from
Dec 14, 2019

Conversation

Gabriella439
Copy link
Collaborator

Fixes #1605

This command lets you transform Text literals into files and record literals
into directories.

Fixes #1605

This command lets you transform `Text` literals into files and record literals
into directories.
Copy link
Collaborator

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

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

Nice! This looks really handy! :)

The command name filesystem reminds me more of NTFS and Ext4 than directory trees. I don't have a great idea for a better name though… Something like directory-tree, generate-directory-tree, gen-dir-tree, dir-tree?!

Also: should this check whether the output directory is empty and abort otherwise? (Overridable with --force or so?). But that's something that could easily be added later on.

@Gabriella439
Copy link
Collaborator Author

@sjakobi: How about to-path? Then at some point we could also have a from-path subcommand that turns a directory tree into a Dhall expression

@Gabriella439
Copy link
Collaborator Author

@sjakobi: Or maybe to-tree / from-tree

@sjakobi
Copy link
Collaborator

sjakobi commented Dec 14, 2019

@sjakobi: Or maybe to-tree / from-tree

to-tree is pretty good, although some notion of files would be nice to have in the name IMHO. to-dir-tree maybe?

@Gabriella439
Copy link
Collaborator Author

@sjakobi: Then maybe to-directory-tree (mainly to use complete words)

@sjakobi
Copy link
Collaborator

sjakobi commented Dec 14, 2019

@sjakobi: Then maybe to-directory-tree (mainly to use complete words)

That's also fine, but remember that we already have dhall repl and dhall diff. ;)

@Gabriella439 Gabriella439 changed the title Add new dhall filesystem command Add new dhall to-directory-tree command Dec 14, 2019
@ari-becker
Copy link

@Gabriel439 some input - a dhall-to-directory-tree command would be massively more useful if, instead of requiring values to be Text, they could be Optional Text, and if the value is None Text then not to create the file. Sort of like how dhall-to-json will omit fields whose values are None Foo if --omitNull is set.

This would make it possible to generate different files on the basis of different inputs, rather than being restricted to generating a fixed set of files.

@Gabriella439 Gabriella439 merged commit 2ee8b0a into master Dec 14, 2019
@Gabriella439 Gabriella439 deleted the gabriel/1605 branch December 14, 2019 17:41
@Profpatsch
Copy link
Member

Great! I’ve been wanting to have/write something like this in nix for a while, but now I can just do it from dhall directly.

@samuela
Copy link

samuela commented Feb 1, 2023

is there an example of how to use this feature?

@mmhat
Copy link
Collaborator

mmhat commented Feb 2, 2023

@samuela There are some examples in the Haddock documentation here and there are also some tests covering the more elaborate fixpoint encoding of a directory tree in the testsuite of the dhall package here. Hope that helps.

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.

Creating multiple file and directory structure using dhall
6 participants