{"id":13566563,"url":"https://github.com/typelevel/paiges","last_synced_at":"2025-07-31T08:46:01.693Z","repository":{"id":37550376,"uuid":"86292872","full_name":"typelevel/paiges","owner":"typelevel","description":"an implementation of Wadler's a prettier printer","archived":false,"fork":false,"pushed_at":"2025-06-08T00:54:29.000Z","size":791,"stargazers_count":188,"open_issues_count":14,"forks_count":30,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-06-29T16:23:19.843Z","etag":null,"topics":["layout","pretty-print","scala"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typelevel.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}},"created_at":"2017-03-27T04:56:35.000Z","updated_at":"2025-06-06T13:02:28.000Z","dependencies_parsed_at":"2023-11-09T12:29:26.801Z","dependency_job_id":"362a62b0-d2b6-4e62-8d40-00a0febbc738","html_url":"https://github.com/typelevel/paiges","commit_stats":{"total_commits":498,"total_committers":27,"mean_commits":"18.444444444444443","dds":0.7008032128514057,"last_synced_commit":"081f127653c3e3d0d896e4f67d41a14594ddd10c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/typelevel/paiges","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fpaiges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fpaiges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fpaiges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fpaiges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typelevel","download_url":"https://codeload.github.com/typelevel/paiges/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fpaiges/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264284424,"owners_count":23584688,"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":["layout","pretty-print","scala"],"created_at":"2024-08-01T13:02:12.114Z","updated_at":"2025-07-31T08:46:01.652Z","avatar_url":"https://github.com/typelevel.png","language":"Scala","funding_links":[],"categories":["Scala"],"sub_categories":[],"readme":"# Paiges\n\n## Overview\n\nPaiges is an implementation of\n[Wadler's \"A Prettier Printer\"](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf).\n\nThe library is useful any time you find yourself generating text or\nsource code where you'd like to control the length of lines (e.g.\nparagraph wrapping). See the [documentation site](http://typelevel.org/paiges/) for some examples.\n\nThe name *Paiges* is a reference to the [Paige compositor](https://en.wikipedia.org/wiki/Paige_Compositor)\nand the fact that it helps you layout pages.\n\n![CI](https://github.com/typelevel/paiges/actions/workflows/ci.yml/badge.svg)\n[![codecov.io](http://codecov.io/github/typelevel/paiges/coverage.svg?branch=master)](http://codecov.io/github/typelevel/paiges?branch=master)\n[![Latest version](https://index.scala-lang.org/typelevel/paiges/paiges-core/latest.svg?color=orange)](https://index.scala-lang.org/typelevel/paiges/paiges-core)\n\n## Quick Start\n\nPaiges supports Scala 2.11, 2.12, 2.13, and 3. It supports JVM, Scala.js, \nand Scala Native platforms.\n\nTo use Paiges in your own project, you can include this snippet in\nyour `build.sbt` file:\n\n```scala\n// use this snippet for the JVM\nlibraryDependencies += \"org.typelevel\" %% \"paiges-core\" % \"0.4.2\"\n\n// use this snippet for JS, Native, or cross-building\nlibraryDependencies += \"org.typelevel\" %%% \"paiges-core\" % \"0.4.2\"\n```\n\nPaiges also provides types to work with Cats via the *paiges-cats*\nmodule:\n\n```scala\n// use this snippet for the JVM\nlibraryDependencies += \"org.typelevel\" %% \"paiges-cats\" % \"0.4.2\"\n\n// use this snippet for JS, Native, or cross-building\nlibraryDependencies += \"org.typelevel\" %%% \"paiges-cats\" % \"0.4.2\"\n```\n\n## Description\n\nThis code is a direct port of the code in section 7 of this paper,\nwith an attempt to be idiomatic in scala while preserving the original\ncode's properties, including laziness.\n\nThis algorithm is optimal and bounded. From the paper:\n\n\u003e Say that a pretty printing algorithm is optimal if it chooses line\n\u003e breaks so as to avoid overflow whenever possible; say that it is\n\u003e bounded if it can make this choice after looking at no more than the\n\u003e next w characters, where w is the line width. Hughes notes that\n\u003e there is no algorithm to choose line breaks for his combinators that\n\u003e is optimal and bounded, while the layout algorithm presented here\n\u003e has both properties.\n\nSome selling points of this code:\n\n 1. Lazy, O(1) concatenation\n 2. Competitive performance (e.g. 3-5x slower than `mkString`)\n 3. Elegantly handle indentation\n 4. Flexible line-wrapping strategies\n 5. Functional cred ;)\n\n## Examples\n\nHere's an example of using Paiges to generate the source code for a\ncase class:\n\n```scala\nimport org.typelevel.paiges._\n\n/**\n * Produces a case class given a name and zero-or-more\n * field/type pairs.\n */\ndef mkCaseClass(name: String, fields: (String, String)*): Doc = {\n  val prefix = Doc.text(\"case class \") + Doc.text(name) + Doc.char('(')\n  val suffix = Doc.char(')')\n  val types = fields.map { case (k, v) =\u003e\n    Doc.text(k) + Doc.char(':') + Doc.space + Doc.text(v)\n  }\n  val body = Doc.intercalate(Doc.char(',') + Doc.line, types)\n  body.tightBracketBy(prefix, suffix)\n}\n\nval c = mkCaseClass(\n  \"Dog\", \"name\" -\u003e \"String\", \"breed\" -\u003e \"String\",\n  \"height\" -\u003e \"Int\", \"weight\" -\u003e \"Int\")\n\nc.render(80)\n// case class Dog(name: String, breed: String, height: Int, weight: Int)\n\nc.render(60)\n// case class Dog(\n//   name: String,\n//   breed: String,\n//   height: Int,\n//   weight: Int\n// )\n```\n\nFor more examples, see the [tutorial](docs/src/main/mdoc/index.md).\n\n## Benchmarks\n\nThe Paiges benchmarks are written against JMH. To run them, you'll\nwant to use a command like this from SBT:\n\n```\nbenchmark/jmh:run -wi 5 -i 5 -f1 -t1 bench.PaigesBenchmark\n```\n\nBy default the values reported are *ops/ms* (operations per\nmillisecond), so higher numbers are better.\n\nThe parameters used here are:\n\n * `-wi`: the number of times to run during warmup\n * `-i`: the number of times to benchmark\n * `-f`: the number of processes to use during benchmarking\n * `-t`: the number of threads to use during benchmarking\n\nIn other words, the example command-line runs one thread in one\nprocess, with a relatively small number of warmups + runs (so that it\nwill finish relatively quickly).\n\n## Organization\n\nThe current Paiges maintainers are:\n\n * [Oscar Boykin](https://github.com/johnynek)\n * [Colt Frederickson](https://github.com/coltfred)\n * [Erik Osheim](https://github.com/non)\n\nPeople are expected to follow the [Typelevel Code of Conduct](http://typelevel.org/conduct.html)\nwhen discussing Paiges on the Github page or other official venues.\n\nConcerns or issues can be sent to any of Paiges' maintainers, or to\nthe Typelevel organization.\n\n## License\n\nPaiges is licensed under the [Apache License, Version 2.0](LICENSE)\n(the \"License\"); you may not use this software except in compliance\nwith the License.\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\nimplied. See the License for the specific language governing\npermissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fpaiges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypelevel%2Fpaiges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fpaiges/lists"}