dynosaur icon indicating copy to clipboard operation
dynosaur copied to clipboard

Fail on the non-exhausted oneOf schema

Open semenodm opened this issue 2 years ago • 1 comments

Maybe we can find a way to fail on compilation if user provided non-exhaustive ADT legs

sealed trait Foo
case class A extends Foo
case class B extends Foo
case class C extends Foo

val schema : Schema[Foo] = Schema.oneOf[Foo]{alt =>
val schemaA : Schema[A] = ???
val schemaB : Schema[B] = ???

alt(schemaA) |+| alt(schemaB) // fail to compile here, because missing schemaC
}

semenodm avatar May 02 '22 14:05 semenodm

This is documented as a limitation, it would be nice if it could be prevented, but I don't really see an easy solution

SystemFw avatar May 14 '22 23:05 SystemFw