You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Possibly include a xmap2Either in config data type, that is a form of invariant applicative functor that handle errors.
In Config type,
defxmap2Either[B, C](that: Config[B])(f: (A, B) =>Either[ReadError, C])(g: C=>Either[WriteError, (A, B)]):Config[C] = {
(self |@| that).apply[(A, B)]((a, b) => (a, b), t =>Some((t._1, t._2))).mapEither(b => f(b._1, b._2))(g)
}
This allows us to implement the following in the companion object
defsequence[A](list: List[Config[A]]):Config[List[A]] = {
list.foldLeft(Pure(Nil:List[A]):Config[List[A]])((a, b) => b. xmap2Either(a)((aa, bb) =>Right( aa :: bb))(t =>Right((t.head, t.tail))))
}
// where Pure isfinalcaseclassPure[A](a: A) extendsConfig[A]
This enables user parse complicated groupings in the env. Although, not a convincing example below, it is essential to make config traversable and allow users to do such things.
Possibly include a
xmap2Either
in config data type, that is a form of invariant applicative functor that handle errors.In Config type,
This allows us to implement the following in the companion object
This enables user parse complicated groupings in the env. Although, not a convincing example below, it is essential to make config traversable and allow users to do such things.
The text was updated successfully, but these errors were encountered: