{"id":16894192,"url":"https://github.com/jsuereth/viewducers","last_synced_at":"2025-03-22T08:31:26.188Z","repository":{"id":24469218,"uuid":"27872844","full_name":"jsuereth/viewducers","owner":"jsuereth","description":"Scala collection views meet Transducers hype","archived":false,"fork":false,"pushed_at":"2015-10-13T12:08:18.000Z","size":244,"stargazers_count":42,"open_issues_count":1,"forks_count":3,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-18T10:11:45.770Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsuereth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-11T13:30:57.000Z","updated_at":"2021-03-19T20:40:43.000Z","dependencies_parsed_at":"2022-08-22T16:40:15.435Z","dependency_job_id":null,"html_url":"https://github.com/jsuereth/viewducers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsuereth%2Fviewducers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsuereth%2Fviewducers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsuereth%2Fviewducers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsuereth%2Fviewducers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsuereth","download_url":"https://codeload.github.com/jsuereth/viewducers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244931482,"owners_count":20534008,"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-13T17:17:58.064Z","updated_at":"2025-03-22T08:31:25.854Z","avatar_url":"https://github.com/jsuereth.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"A project based on: https://gist.github.com/odersky/6b7c0eb4731058803dfd.\n\n\nVIEWDUCTION -  The intersection of Transducers (Fold transformers) and Scala collection Views.\n\n\nThis project attempts to improve the implementation \u0026 performance of Scala collection views via the following ideas:\n\n* We do not need to memoize views, instead we need to make the user stage all desired operations and then execute as needed.\n* We should do as little work as possible on most operations\n* We should be able to do minor performane tweaks to staged operations\n* We will make any operation which executes a view have an ugly character (`!`) so people know it's effectful\n* Transducers represent an excellent way to stage computation that will be performed via a fold.\n* We need extensive microbenchmarking to test out different possible optimisations and code traversals, as well as understand the overhead.\n* We should be able to avoid excessive bytecode overhead through simple understanding of Scala =\u003e JVM features.\n\n## Transducers\n\nThis library provides a very minimal and complete Transducers library.  This transducers library is optimised for use\nwith the Scala collections library in its current form.  We won't dig into the details of transducers in this readme,\nbut will set up a tutorial on them separately.\n\n\n## StagedCollections\n\nA Staged collection is a collection where you stage Transducers to execute against it.   Any operation devoid of a `!`\nis one that simply append a new Transducer onto the stack.   The `toString` method of a StagedCollection will attempt to\nshow you the stack of transducers.  \n\n**Note: The `toString` could grow out of control and is meant purely for debugging, not logging.**\n\nIf you're only interested in the new, delineated, API try the following.\n\n\n```\n\u003e import com.jsuereth.collections._\nimport com.jsuereth.collections._\n\nscala\u003e val test = StagedCollectionOps(Vector(1,2,3))\ntest: com.jsuereth.collections.StagedCollectionOps[Int] = Vector(1, 2, 3) -\u003e identity -\u003e done\n\nscala\u003e val test2 = test.map(_ + 1).take(2).zipWithIndex\ntest2: com.jsuereth.collections.StagedCollectionOps[(Int, Int)] = Vector(1, 2, 3) -\u003e identity -\u003e Map(\u003cfunction1\u003e) -\u003e Slice(0, 2) -\u003e ZipWithIndex -\u003e done\n\nscala\u003e test2.to_![Vector]\nres0: Vector[(Int, Int)] = Vector((2,0), (3,1))\n```\n\n## Views\n\nThis library attempts to mimic, as much as it can, the existing view API via an abstraction on top of `StagedCollection`s, called `View`.\nA View is something which will stage all the operations it can, but certain operations will force it to run against the original collection.\n\nNote:  Unlike Scala's current views, these will NEVER memoize the partial-results of operations.   Upon terminal operation it will\nattempt to read from the original collection again.  Like Scala's current views, these also do not denote which operations are terminal.  They\nare meant as a drop-in replacement for existing views.\n\n```\nscala\u003e import com.jsuereth.collections.View._\nimport com.jsuereth.collections.View._\n\nscala\u003e Vector(1,2,3,4).stagedView.filter(_%2==0)\nres0: com.jsuereth.collections.View[Int,scala.collection.immutable.Vector[Int]] = SimpleView(Vector(1, 2, 3, 4) -\u003e identity -\u003e Filter(\u003cfunction1\u003e) -\u003e done,scala.collection.IndexedSeq$$anon$1@5bf6e33b)\n\nscala\u003e res0.force\nres1: scala.collection.immutable.Vector[Int] = Vector(2, 4)\n\nscala\u003e \"Hello\".stagedView.filter(_ % 2 == 0).force\nres2: String = Hll\n\nscala\u003e \"Hello\".stagedView.filter(_ % 2 == 0)\nres3: com.jsuereth.collections.View[scala.collection.generic.IsTraversableLike.stringRepr.A,String] = SimpleView(Hello -\u003e identity -\u003e Filter(\u003cfunction1\u003e) -\u003e done,scala.Predef$$anon$3@450f9792)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsuereth%2Fviewducers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsuereth%2Fviewducers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsuereth%2Fviewducers/lists"}