Scala 3 类型与 monad
我有类似:
type RawListResponse[T] = Either[ResponseException[String, circe.Error], List[T]]
type RawOptionResponse[T] = Either[ResponseException[String, circe.Error], Option[T]]
用于转换器的东西:
given convList[T]: Conversion[RawListResponse[T], MyListResponse[T]] with
def apply(
raw: RawListResponse[T],
): MyListResponse[T] = raw.left.map { (respExc: ResponseException[String, circe.Error]) =>
respExc.getMessage
}
将其合并到一个 F[_] 中会很好。而不是使用选项、列表等转换器。
有什么想法吗?谢谢!
I have smth like:
type RawListResponse[T] = Either[ResponseException[String, circe.Error], List[T]]
type RawOptionResponse[T] = Either[ResponseException[String, circe.Error], Option[T]]
which are used in converters:
given convList[T]: Conversion[RawListResponse[T], MyListResponse[T]] with
def apply(
raw: RawListResponse[T],
): MyListResponse[T] = raw.left.map { (respExc: ResponseException[String, circe.Error]) =>
respExc.getMessage
}
would be nice to merge it into one F[_]. Instead of having converters for Options, Lists etc.
Any ideas ? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我找到了解决方案:
ok I found the solution: