{"id":25221583,"url":"https://github.com/learningobjectsinc/scaloi","last_synced_at":"2025-10-25T20:30:18.046Z","repository":{"id":54193458,"uuid":"147968975","full_name":"learningobjectsinc/scaloi","owner":"learningobjectsinc","description":"Fyne Thyngges provided by Learning Objects, for Use with ScalaZ and Libraries of a similar Nature and Quality.","archived":false,"fork":false,"pushed_at":"2021-03-04T01:46:39.000Z","size":1046,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":13,"default_branch":"master","last_synced_at":"2023-08-13T23:21:58.864Z","etag":null,"topics":["fine","functional-programming","scala","scalaz","things","utility"],"latest_commit_sha":null,"homepage":"","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/learningobjectsinc.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}},"created_at":"2018-09-08T20:51:10.000Z","updated_at":"2022-10-11T21:03:31.000Z","dependencies_parsed_at":"2022-08-13T08:50:45.896Z","dependency_job_id":null,"html_url":"https://github.com/learningobjectsinc/scaloi","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learningobjectsinc%2Fscaloi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learningobjectsinc%2Fscaloi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learningobjectsinc%2Fscaloi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learningobjectsinc%2Fscaloi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learningobjectsinc","download_url":"https://codeload.github.com/learningobjectsinc/scaloi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238202163,"owners_count":19433177,"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":["fine","functional-programming","scala","scalaz","things","utility"],"created_at":"2025-02-10T22:52:50.222Z","updated_at":"2025-10-25T20:30:17.712Z","avatar_url":"https://github.com/learningobjectsinc.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scaloi\n\nFyne Thyngges provided by Learning Objects, for Use with ScalaZ and Libraries of a similar Nature and Quality.\n\n```scala\nlibraryDependencies += \"com.learningobjects\" %% \"scaloi\" % \"0.3.1\"\n```\n\n## Monad conversion syntax\n\nConvenient syntax for converting to and among monads.\n\n### Disjunction\n\nSyntaces, including the flappy birds, to operate within `\\/` disjunctions.\n\n```scala\nfor {\n  _ \u003c- 0.right[Err] // ScalaZ\n  _ \u003c- Option(1)  \\/\u003e  Err.IsNone // ScalaZ\n  _ \u003c- true       \\/\u003e  Err.IsFalse\n  _ \u003c- false      \\/\u003e! Err.IsTrue\n  _ \u003c- Try(2)     \\/\u003e  Err.forThrowable\n  _ \u003c- Try(3)     \\/\u003e| Err.IsFailure\n  _ \u003c- \\@~*/(op) -\\/\u003e  Err.forThrowable\n} yield ???\n```\n\nArrow programming with disjunctions.\n\n```scala\ncreateAttempt(...)   --\u003e\n  submitAttempt     |--\u003e\n  createAttempt(...) --\u003e\n  submitAttempt      --\u003e\n  gradeAttempt      |--\u003e\n  createAttempt(...)\n```\n\n### Try\n\nSyntaces to operate within the `Try` monad.\n\n```scala\nfor {\n  _ \u003c- 0.success\n  _ \u003c- Ex(\"Bah\").failure\n  _ \u003c- Option(1) \u003c@~* Ex(\"None\")\n  _ \u003c- true      \u003c@~* Ex(\"false\")\n  _ \u003c- false     *~@\u003e Ex(\"true\")\n  _ \u003c- true      \u003c@~* Ex(\"false\") *\u003e 3 // add a starry bird\n  _ \u003c- 2.right[Ex].toTry\n  _ \u003c- this.asInstanceOf_![That]\n  _ \u003c- true either 3      orFailure         Ex(\"false\")\n  _ \u003c- Option(Try(4))     flatToTry         Ex(\"None\")\n  _ \u003c- Option(5)          thenFailure      (Ex(\"None\"), 6)\n  _ \u003c- Option(\"Some\")     thenHollowFailure Ex.apply\n  _ \u003c- Option(\"Some\")     elseHollowVictory Ex.apply\n  _ \u003c- Option(Ex(\"Some\")) toFailure         8\n} yield ???\n```\n\n### Validation\n\nSyntaces to operate within the `Validation` monad.\n\n```scala\nfor {\n  _ \u003c- 0.success[Err] // ScalaZ\n  _ \u003c- Option(1) elseInvalid Err.IsNone\n  _ \u003c- Option(\"bah\") thenInvalid Err.forString\n  _ \u003c- Option(\"bah\") thenInvalid 2\n  _ \u003c- true elseFailure (Err.IsFalse, 3)\n  _ \u003c- false thenFailure (Error.IsTrue, 4)\n} yield ???\n```\n\nSimilarly for `ValidationNel`.\n\n## Hypermonad\n\nThe `Hypermonad` typeclass describes a monad that supports mapping flatter\nthan flat. For example, given a list of ids and a\nfunction from an id to perhaps a list of entities, it can flatter map to\na single list of all the associated entities.\n\n```scala\nval entityMap: Map[Long, List[Entity]] = ???\nval ids: List[Long] = ???\nval entities: List[Entity] = ids.flatterMap(entityMap.get)\n```\n\nHypermonads can also flatten flatter.\n\n```scala\nval list3: List[List[List[Int]]] = ???\nval ints: List[Int] = list3.hyperFlatten\n```\n\n## List tree\n\nA strict tree, much as `StrictTree`, but based on `List` and thus avoidant\nof the moral perils of `Vector`.\n\n```scala\nval tree = 0.listNode(1.listLeaf, 2.listLeaf)\ntree.flatten must_=== List(0, 1, 2)\n```\n\n## Zero\n\nEvidence for a type that has a zero but is not necessarily semigroupal.\n\n```scala\ntrait Zero[A] {\n  def zero: A\n  def isZero(a: A): Boolean\n}\n```\n\nAll `Monoid`s with `Equal`, `IsEmpty`s and `Numeric`s have a `Zero`.\n\n### Syntax\n\nA minimal syntax is provided. Other zeroic syntaces are provided in\ndifferent contexts.\n\n```scala\nNil.isZero must_=== true\n1.nonZero must_=== true\n```\n\n## New Zealand Option\n\n`OptionNZ` wraps a value in an `Option`, filtering out any zeroes.\nUse this, for example, to filter out empty strings.\n\n```scala\nOptionNZ(\"\") must_=== None\nOptionNZ(\"Bob\") must_=== Some(\"Bob\")\n```\n\n## New Brunswick Option\n\nRelated, `OptionNB` wraps a `String` in an `Option`, filtering out any\nblanks.\n\n```scala\nOptionNB(\" \") must_=== None\nOptionNZ(\"Old Brunswick\") must_=== Some(\"Old Brunswick\")\n```\n\n## South Carolina Fold\n\nThe `foldSC` operation, aka ``??\u003e``, short-circuits a function to the resulting\nzero if the parameter to the function is an empty collection. Use this, for\nexample, to avoid performing unnecessary I/O operations or calling database\nlibraries that fail on empty lists.\n\n```scala\nval ids: List[Long] = ???\nval loadUsers: List[Long] =\u003e List[User] = ???\nval users: List[User] = ids ??\u003e loadUsers\n```\n\n## Bucket generational data structures\n\nUsed to efficiently track recent data.\n\n### Bucket generational dedup\n\nTracks which data have been recently added, for the purposes of\ndeduplication.\n\n```scala\nval dedup = BucketGenerationalDedup.empty[Symbol](3.minutes, 3)\ndedup += 'a\ndedup contains 'a must_=== true\nsleep(4.minutes)\ndedup contains 'a must_=== false\n```\n\n### Bucket generational bag\n\nTracks how many of each datum have been recently added to the bag.\n\n```scala\nval bag = BucketGenerationalBag.empty[Symbol](3.minutes, 3)\nbag += 'a\nbag count 'a must_=== 1\nsleep(1.minutes)\nbag += 'a\nbag count 'a must_=== 2\nsleep(4.minutes)\nbag count 'a must_=== 0\n```\n\n## Unbounded blocking fair keyed queue\n\nA queue of key-value pairs that releases values fairly across the keyspace.\n\n```scala\nval queue = UnboundedBlockingFairKeyedQueue.empty[Symbol, Int]\nqueue.offer('a -\u003e 1)\nqueue.offer('a -\u003e 2)\nqueue.offer('b -\u003e 3)\nqueue.take() must_=== 1\nqueue.take() must_=== 3\nqueue.take() must_=== 2\n```\n\n## Set delta\n\nTracks the delta between two sets.\n\n```scala\nval set0: Set[Int] = ???\nval set1: Set[Int] = ???\nval delta = SetDelta from set0 to set1\nset0 |: delta must_=== set1\n```\n\n## Many fine option enhancements\n\nWith added support for `util.Optional`. Including, but not limited\nto:\n\n```scala\nOption(a) \u003c|? println     // tap on the contents\nOption(a) -\u003c| sys.exit()  // tap on absence\nOption(a) flatOpt fa      // flat map to nullable\nOption(a) orZ             // get or zero\nOption(a) foldZ fa        // map or zero\nOption(a) filterNZ        // filter non-zero\nOption(a) mapNZ fa        // map then filter non-zero\nOption(a0) - a1           // filter out\nOption(a).isTrue          // container of truth\nOption(a0) =\u0026= Option(a1) // both present and equal\nOption(a0) max a1         // maximality\nOption(a0) max Option(a1) // co-maximality\nOption(a0) min a1         // minimality\nOption(a0) min Option(a1) // co-minimality\nOption(a) when b          // filter by boolean\nOption(a) unless b        // filter by invert boolean\nOption(a).accept[Dog]     // filter by type\nOption(a) \\\u0026/ Option(b)   // to these\n```\n\n## Many fine boolean enhancements\n\nWith added support for `lang.Boolean`. Including, but not limited to:\n\n```scala\nbool noption a               // some if false, else none\nbool flatOption optA         // none if false, or else optA\nbool flatNoption optA        // none if true, or else optA\nfalse ??? Some(1) must_=== 0 // zero if false or absent, else a\ntrue  \u003c|? println(\"true\")    // tap on true\nfalse \u003c|! println(\"false\")   // tap on false\nbool either a orElse optA    // flat either or\n```\n\n## Either neither both\n\nThe `\\|/` bifunctor admits either the left, the right, both or neither.\nContrast with `\\\u0026/` which refuses to admit neither and `\\/` which\nadmits neither neither nor both.\n\n```scala\nval optA: Option[A] = ???\nval optB: Option[B] = ???\nval ab = optA \\|/ optB\nval cd = enb bimap (fac, fbd)\n```\n\n## Font\n\nConsider the [blessed](https://github.com/merlinorg/FiraLorde) font.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearningobjectsinc%2Fscaloi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearningobjectsinc%2Fscaloi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearningobjectsinc%2Fscaloi/lists"}