Skip to content

tabdulradi/happypath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

happypath

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

Usage

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")

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages