Skip to content
vic

tabdulradi/happypath

Makes union types work with for-comprehensions (like scala.Either, but without the allocation cost).

tabdulradi/happypath.json
{
"createdAt": "2021-03-27T00:30:21Z",
"defaultBranch": "main",
"description": "Makes union types work with for-comprehensions (like scala.Either, but without the allocation cost).",
"fullName": "tabdulradi/happypath",
"homepage": null,
"language": "Scala",
"name": "happypath",
"pushedAt": "2021-10-19T08:25:46Z",
"stargazersCount": 16,
"topics": [],
"updatedAt": "2024-04-13T03:43:51Z",
"url": "https://github.com/tabdulradi/happypath"
}

Makes union types work with for-comprehensions (like scala.Either, but without the allocation cost).

import com.abdulradi.happypath.UnhappyCase
enum AppError derives UnhappyCase:
case Err1(foo: String)
case Err2(bar: Int)
@main def app(): Unit =
val intOrErr: AppError | Int = 42
val strOrErr: AppError | String = "test"
for
i <- intOrErr
s <- strOrErr
do println(s"$s $i")