how to derive Write[Either[T,U]] #1838
Answered
by
jatcwang
berserk-fan
asked this question in
Q&A
-
Is it possible to derive Write[Either[T,U]] from Write[T] and Write[U]? |
Beta Was this translation helpful? Give feedback.
Answered by
jatcwang
Mar 21, 2023
Replies: 1 comment 2 replies
-
Not generically no. How do we know wheter a result column contains T or U? What might work for you use to have a sealed trait / enum, and deriving JSON encoder/decoders for it. Then use the doobie's circe integration to read the column. For an example see https://stackoverflow.com/questions/67789229/how-i-can-insert-case-object-as-jsonb-format-via-doobie |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
berserk-fan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not generically no. How do we know wheter a result column contains T or U?
What might work for you use to have a sealed trait / enum, and deriving JSON encoder/decoders for it. Then use the doobie's circe integration to read the column. For an example see https://stackoverflow.com/questions/67789229/how-i-can-insert-case-object-as-jsonb-format-via-doobie