{"id":15050641,"url":"https://github.com/tulz-app/tuplez","last_synced_at":"2025-04-10T02:20:03.986Z","repository":{"id":43508271,"uuid":"321437117","full_name":"tulz-app/tuplez","owner":"tulz-app","description":"Scala tuple composition","archived":false,"fork":false,"pushed_at":"2024-08-19T21:31:06.000Z","size":138,"stargazers_count":9,"open_issues_count":14,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T03:44:16.032Z","etag":null,"topics":["composition","scala","tuple"],"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/tulz-app.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-12-14T18:26:55.000Z","updated_at":"2024-12-09T19:53:38.000Z","dependencies_parsed_at":"2025-02-16T10:32:24.767Z","dependency_job_id":null,"html_url":"https://github.com/tulz-app/tuplez","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tulz-app%2Ftuplez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tulz-app%2Ftuplez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tulz-app%2Ftuplez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tulz-app%2Ftuplez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tulz-app","download_url":"https://codeload.github.com/tulz-app/tuplez/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142920,"owners_count":21054672,"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":["composition","scala","tuple"],"created_at":"2024-09-24T21:28:37.179Z","updated_at":"2025-04-10T02:20:03.947Z","avatar_url":"https://github.com/tulz-app.png","language":"Scala","readme":"![Maven Central](https://img.shields.io/maven-central/v/app.tulz/tuplez-full_sjs1_2.13?versionPrefix=0.4)\n\n### tuplez\n\nTuple composition in Scala and Scala.js.\n\n```scala\n// tupleN + scalar, scalar + tupleN, tupleN + tupleM, up to Tuple22\n\"app.tulz\" %%% \"tuplez-full\" % \"0.4.0\"\n\n// or\n\n// tupleN + scalar, scalar + tupleN, tupleN + tupleM, up to Tuple10\n\"app.tulz\" %%% \"tuplez-full-light\" % \"0.4.0\"\n\n// or\n\n// tupleN + scalar, up to Tuple22\n\"app.tulz\" %%% \"tuplez-basic\" % \"0.4.0\"\n\n// or\n\n// tupleN + scalar, up to Tuple10 \n\"app.tulz\" %%% \"tuplez-basic-light\" % \"0.4.0\" \n```\n\n```scala\n// utilities to build API's that allow using a FunctionN[A, B, C, ... Out] instead of Function1[TupleN[A, B, C, ...], Out] \n\"app.tulz\" %%% \"tuplez-apply\" % \"0.4.0\"\n```\n\nPublished for Scala `2.12`, `2.13` and `3.2.1`, JVM and Scala.js 1.5.1+.\n\n### Source code\n\nSource code is 100% generated. \n\n## Composition\n\n`app.tulz.tuplez.TupleComposition`\n\n```scala\nabstract class Composition[L, R] {\n  type Composed\n  val compose: (L, R) =\u003e Composed\n  def decompose(c: Composed): (L, R)\n}\n```\n\nImplicit values are provided for composing tuples with tuples, and tuples with scalars (both prepending and appending). \n\nImplicits are defined by the generated code.\n\nThe companion object provides utility functions to compose/decompose two tuples (or a tuple and a scalar)\n\n```scala\nobject TupleComposition {\n\n  def compose[L, R](l: L, r: R)(implicit composition: Composition[L, R]): composition.Composed = composition.compose(l, r)\n  def decompose[L, R, C](c: C)(implicit composition: Composition.Aux[L, R, C]): (L, R)         = composition.decompose(c)\n\n}\n\n```\n\nExamples:\n\n```scala\nimport app.tulz.tuplez.TupleComposition\n\nTupleComposition.compose( Tuple1(1), Tuple1(2) ) // (1, 2)\nTupleComposition.compose( 1, 2 ) // (1, 2)\nTupleComposition.compose( (1, 2, 3, 4), (5, 6) ) // (1, 2, 3, 4, 5, 6)\nTupleComposition.compose( (1, 2, 3), 4 ) // (1, 2, 3, 4)\nTupleComposition.compose( 1,  (2, 3, 4) ) // (1, 2, 3, 4)\nTupleComposition.compose( (1, 2, 3), Tuple1(4) ) // (1, 2, 3, 4)\nTupleComposition.compose( Tuple1(1),  (2, 3, 4) ) // (1, 2, 3, 4)\nTupleComposition.compose( (1, 2, 3), () ) // (1, 2, 3)\nTupleComposition.compose( (),  (1, 2, 3) ) // (1, 2, 3)\n// etc\n```\n\n## Apply converters\n\n`app.tulz.tuplez.ApplyConverter`\n\nUtilities for converting `FunctionN[..., Out]` into `Function1[TupleN[...], Out]`\n\nExample:\n\n```scala\nimport app.tulz.tuplez._\n\nobject instances extends ApplyConverters[String] \n// in order to make type and implicits resolution possible, the apply converters are generated for a fixed output type\nimport instances._\n\nval acceptingTupledFunc: ((Int, Int, Int, Int) =\u003e String) =\u003e String = func =\u003e func((1, 2, 3, 4))\nval nonTupledFunction = (x1: Int, x2: Int, x3: Int, x4: Int) =\u003e s\"I return [${x1}, ${x2}, ${x3}, ${x4}]\"\nassert(acceptingTupledFunc(toTupled4(nonTupledFunction)) == \"I return [1, 2, 3, 4]\")\n```\n\n## Intended usage\n\nSimple example:\n\n```scala\nimport app.tulz.tuplez._\n\ncase class MyStructure[T](\n  data: T\n) {\n\n  def appendScalar[U](value: U)(implicit composition: Composition[T, U]): MyStructure[composition.Composed] = \n    copy(data = composition.compose(data, value)) \n // or \n // copy(data = TupleComposition.compose(data, value))\n\n}\n```\n\nA more complete example: https://github.com/tulz-app/frontroute/blob/main/src/main/scala/io/frontroute/DirectiveApplyConverters.scala\n\n\n## Author\n\nIurii Malchenko – [@yurique](https://twitter.com/yurique) \n\n\n## License\n\n`tuplez` is provided under the [MIT license](https://github.com/tulz-app/tuplez/blob/main/LICENSE.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftulz-app%2Ftuplez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftulz-app%2Ftuplez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftulz-app%2Ftuplez/lists"}