{"id":16349005,"url":"https://github.com/mstksg/dhall-text-shell","last_synced_at":"2025-04-12T13:05:04.451Z","repository":{"id":62436409,"uuid":"483923296","full_name":"mstksg/dhall-text-shell","owner":"mstksg","description":"dhall text but provide shell commands as function arguments","archived":false,"fork":false,"pushed_at":"2022-05-01T05:56:56.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T00:12:11.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mstksg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-21T05:51:03.000Z","updated_at":"2024-02-27T08:07:10.000Z","dependencies_parsed_at":"2022-11-01T21:30:38.039Z","dependency_job_id":null,"html_url":"https://github.com/mstksg/dhall-text-shell","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstksg%2Fdhall-text-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstksg%2Fdhall-text-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstksg%2Fdhall-text-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstksg%2Fdhall-text-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mstksg","download_url":"https://codeload.github.com/mstksg/dhall-text-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223518559,"owners_count":17158689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T00:56:36.038Z","updated_at":"2024-11-07T13:05:50.090Z","avatar_url":"https://github.com/mstksg.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"dhall-text-shell\n================\n\n`dhall text` and `dhall to-directory-tree` require the expression (or file\nleaves) to be `Text`.  But what if it was able to also render expressions of\ntype `(Text -\u003e Text) -\u003e Text` (or `(Text -\u003e Text) -\u003e directory tree`), and be\ngiven a shell argument as the `Text -\u003e Text` ?\n\n```dhall\n-- testfile.dhall\nlet text = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v21.1.0/Prelude/Text/package.dhall\nin  \\(f : Text -\u003e Text) -\u003e text.concatMapSep \",\" Text f [ \"hello\", \"world\" ]\n```\n\nWould give:\n\n```\n$ dhall-text-shell --file testfile.dhall --argCmd cat\nhello,world\n$ dhall-text-shell --file testfile.dhall --argCmd \"tr '[:lower:]' '[:upper:]'\"\nHELLO,WORLD\n$ dhall-text-shell --file testfile.dhall --argCmd \"pandoc -f markdown -t html\"\n\u003cp\u003ehello\u003c/p\u003e\n,\u003cp\u003eworld\u003c/p\u003e\n$ dhall-text-shell --file testfile.dhall --argCmd \"md5sum -z\"\n5d41402abc4b2a76b9719d911017c592  -,7d793037a0760186574b0282f2f435e7  -\n```\n\nError messages:\n\n```\n$ dhall-text-shell --file testfile.dhall\nError: Expression doesn't match annotation\n\n- Text\n+ .. -\u003e .. (a function type)\n$ dhall-text-shell --file testfile.dhall --argCmd cat --argCmd cat\nError: Expression doesn't match annotation\n\n- .. -\u003e ..  (a function type)\n+ Text\n```\n\nSupports multiple arguments as well:\n\n```dhall\n-- testfile2.dhall\nlet text = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v21.1.0/Prelude/Text/package.dhall\nin  \\(f : Text -\u003e Text) -\u003e \\(g : Text -\u003e Text) -\u003e text.concatMapSep \",\" Text f [ \"hello\", g \"world\" ]\n```\n\n```\n$ dhall-text-shell --file testfile2.dhall --argCmd cat --argCmd \"tr '[:lower:]' '[:upper:]'\"\nhello,WORLD\n```\n\nThis is essentially a very minimal \"FFI\" for dhall, since it doesn't require\nextending anything in the language.  It just requires you to parameterize your\nprogram on that ffi function.\n\nNote that for this to work meaningfully, your shell command must be \"pure\": it\nmust return the same stdout for any stdin, and shouldn't observably affect the\nworld every time it is run.\n\nThis also supports `dhall to-directory-tree` as well with a `--directory-tree`\nflag, and in a similar fashion it takes a function `(Text -\u003e Text) -\u003e\n(directory tree record)`, to be supplied the shell function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstksg%2Fdhall-text-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmstksg%2Fdhall-text-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstksg%2Fdhall-text-shell/lists"}