{"id":18041113,"url":"https://github.com/mcanlas/bash-monad","last_synced_at":"2026-04-30T15:32:35.887Z","repository":{"id":65098037,"uuid":"581363662","full_name":"mcanlas/bash-monad","owner":"mcanlas","description":"A DSL for Bash scripts, in Scala","archived":false,"fork":false,"pushed_at":"2026-03-26T13:03:56.000Z","size":109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-27T04:28:19.428Z","etag":null,"topics":["bash","dsl","scala","unix"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcanlas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-23T01:16:30.000Z","updated_at":"2026-03-26T13:04:00.000Z","dependencies_parsed_at":"2023-10-01T17:31:50.709Z","dependency_job_id":"966ec4fa-8c91-488c-a984-b9ea3935c169","html_url":"https://github.com/mcanlas/bash-monad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mcanlas/bash-monad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcanlas%2Fbash-monad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcanlas%2Fbash-monad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcanlas%2Fbash-monad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcanlas%2Fbash-monad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcanlas","download_url":"https://codeload.github.com/mcanlas/bash-monad/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcanlas%2Fbash-monad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32469344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bash","dsl","scala","unix"],"created_at":"2024-10-30T15:08:34.497Z","updated_at":"2026-04-30T15:32:35.872Z","avatar_url":"https://github.com/mcanlas.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bash-monad\n\nExploring Bash script generation with a Scala DSL\n\n## In action\n\nUsing a DSL, Bash programs can be encoded as a large, monadic data structure.\n\n```scala\nval program =\n  for {\n    _ \u003c- BashProgram(\"#!/bin/bash\")\n\n    // seperate steps are padded with newlines\n    _ \u003c- BashProgram(\"set -euo pipefail\")\n\n    // positional argument extraction\n    tuple \u003c- Args\n      .string(\"DEPLOY_REGION\")\n      .string(\"PAYLOAD_NAME\")\n\n    // downstream commands can statically depend on variables declared earlier\n    (deployRegion, payloadName) = tuple\n\n    // bash interpolator allows for proper escaping and inline use of bash variables\n    // note that the type of `deployRegion` is not `String`\n    _ \u003c- Cmd(\"echo\", bash\"\"\"deploying to \"$deployRegion\" \\o/ woohoo!!\"\"\")\n\n    // this could be defined externally\n    awsLambda = MultiLineCommand(\"aws\", \"lambda\")\n\n    // pretty printing for subcommand style commands\n    _ \u003c- Aws.Lambda(\"list-tags\")\n      .opt(\"foo\")\n      .opt(\"payload\", payloadName)\n      .opt(\"region\", deployRegion)\n  } yield ()\n\nval compiled =\n  Encoder.encode(program)\n\nprintln(compiled)\n```\n\nWhen compiled, the above will yield the following Bash script:\n\n```bash\n#!/bin/bash\n\nset -euo pipefail\n\nif [ $# -ne 2 ]; then\n  echo \"Usage: $0 \u003cDEPLOY_REGION\u003e \u003cPAYLOAD_NAME\u003e\"\n  exit 1\nfi\n\nDEPLOY_REGION=$1\nPAYLOAD_NAME=$2\n\necho deploying to \\\"${DEPLOY_REGION}\\\" \\\\o/ woohoo\\!\\!\n\naws lambda list-tags \\\n  --foo \\\n  --payload \\\n    \"$PAYLOAD_NAME\" \\\n  --region \\\n    \"$DEPLOY_REGION\"\n```\n\n\n## Elsewhere\n\nA `BashProgram[_]` feels isomorphic to a [`Writer[_]` monad](https://typelevel.org/cats/datatypes/writer.html) whose logging type is `List[String]` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcanlas%2Fbash-monad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcanlas%2Fbash-monad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcanlas%2Fbash-monad/lists"}