{"id":21032852,"url":"https://github.com/jancvanb/strify","last_synced_at":"2025-03-13T19:48:10.692Z","repository":{"id":85594526,"uuid":"443826336","full_name":"JanCVanB/Strify","owner":"JanCVanB","description":"A Roc library for converting things to Str","archived":false,"fork":false,"pushed_at":"2022-01-07T01:03:47.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T15:40:47.470Z","etag":null,"topics":["library","pretty-print","roc","stringify"],"latest_commit_sha":null,"homepage":"https://roc-lang.org","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"upl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JanCVanB.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}},"created_at":"2022-01-02T17:21:22.000Z","updated_at":"2022-02-03T06:48:30.000Z","dependencies_parsed_at":"2023-05-30T04:00:39.517Z","dependency_job_id":null,"html_url":"https://github.com/JanCVanB/Strify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanCVanB%2FStrify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanCVanB%2FStrify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanCVanB%2FStrify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanCVanB%2FStrify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JanCVanB","download_url":"https://codeload.github.com/JanCVanB/Strify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475141,"owners_count":20296708,"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":["library","pretty-print","roc","stringify"],"created_at":"2024-11-19T12:46:16.411Z","updated_at":"2025-03-13T19:48:10.670Z","avatar_url":"https://github.com/JanCVanB.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strify\n\nA [Roc](https://roc-lang.org) library for converting things to `Str`\n\n## Usage\n\nSee [`./example.roc`](https://github.com/JanCVanB/Strify/blob/main/example.roc):\n```\n#!/usr/bin/env roc\n\napp \"example\"\n    packages { pf: \"./roc/examples/cli/platform\" }\n    imports [ pf.Stdout.{ line }, pf.Task.{ await }, Strify.{ strify } ]\n    provides [ main ] to pf\n\nmain = \n    _ \u003c- await (line (strify (Str \"Six\")))\n    _ \u003c- await (line (strify (Bool True)))\n    _ \u003c- await (line (strify (Num 6)))\n    _ \u003c- await (line (strify (ListStr [\"Strify\", \"likes\", \"Strs\"])))\n    _ \u003c- await (line (strify (ListBool [True, False, True])))\n    _ \u003c- await (line (strify (ListNum [1, 2, 3])))\n    _ \u003c- await (line (strify (ListListStr [[\"Strify\"], [\"likes\"], [\"Strs\"]])))\n    _ \u003c- await (line (strify (ListListBool [[True], [False], [True]])))\n    _ \u003c- await (line (strify (ListListNum [[1], [2], [3]])))\n    line \":)\"\n```\n\nOutput:\n```\n[nix-shell:~/code/Strify]$ ./roc/target/release/roc example.roc\n🔨 Rebuilding host... Done!\n\"Six\"\nTrue\n6\n[\"Strify\", \"likes\", \"Strs\"]\n[True, False, True]\n[1, 2, 3]\n[[\"Strify\"], [\"likes\"], [\"Strs\"]]\n[[True], [False], [True]]\n[[1], [2], [3]]\n:)\n```\n\n\n## Why the tag?\n\nThe `Str` / `ListBool` / `ListListNum` tag before your data is (unfortunately) necessary.\n\nRoc doesn't support type introspection,\nand [abilities](https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Abilities/near/259248567) aren't implemented yet\n(when they are, [`Str`-ification might be supported natively](https://docs.google.com/document/d/1kUh53p1Du3fWP_jZp-sdqwb5C9DuS43YJwXHg1NzETY/edit#heading=h.y8k2p5snq1la)).\nTherefore, Strify can only support specific input types and needs you to tell it your data's type.\n\n## Supported input types\n\n### `Str`\n\n```coffee\nstrify (Str \"\") == \"\\\"\\\"\"\nstrify (Str \"Text\") == \"\\\"Text\\\"\"\n```\n\n### `Bool`\n\n```coffee\nstrify (Bool False) == \"False\"\nstrify (Bool True) == \"True\"\n```\n\n### `Num`\n\n```coffee\nstrify (Num 0) == \"0\"\nstrify (Num 6) == \"6\"\n```\n\n### `List Str`\n\n```coffee\nstrify (ListStr []) == \"[]\"\nstrify (ListStr [\"a\", \"b\", \"c\"]) == \"[\\\"a\\\", \\\"b\\\", \\\"c\\\"]\"\n```\n\n### `List Bool`\n\n```coffee\nstrify (ListBool []) == \"[[]]\"\nstrify (ListBool [True, False, True]) == \"[True, False, True]\"\n```\n\n### `List Num`\n\n```coffee\nstrify (ListNum []) == \"[]\"\nstrify (ListNum [1, 2, 3]) == \"[1, 2, 3]\"\n```\n\n### `List List Str`\n\n```coffee\nstrify (ListListStr [[]]) == \"[[]]\"\nstrify (ListListStr [[\"a\"], [\"b\"], [\"c\"]]) == \"[[\\\"a\\\"], [\\\"b\\\"], [\\\"c\\\"]]\"\n```\n\n### `List List Bool`\n\n```coffee\nstrify (ListListBool [[]]) == \"[[]]\"\nstrify (ListListBool [[True], [False], [True]]) == \"[[True], [False], [True]]\"\n```\n\n### `List List Num`\n\n```coffee\nstrify (ListListNum [[]]) == \"[[]]\"\nstrify (ListListNum [[1], [2], [3]]) == \"[[1], [2], [3]]\"\n```\n\n## Formatting\n\nFormatting mimics the behavior of\n[JavaScript's JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify),\nexcept that `true` and `false` are capitalized.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjancvanb%2Fstrify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjancvanb%2Fstrify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjancvanb%2Fstrify/lists"}