-
Notifications
You must be signed in to change notification settings - Fork 9
/
syntax.scala
22 lines (15 loc) 路 943 Bytes
/
syntax.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package io.github.arainko.ducktape
import io.github.arainko.ducktape.internal.{ FallibleTransformations, TotalTransformations }
extension [Source](source: Source) {
inline def to[Dest]: Dest = TotalTransformations.between[Source, Dest](source, "transformation")
def into[Dest]: AppliedBuilder[Source, Dest] = AppliedBuilder[Source, Dest](source)
transparent inline def via[Func](inline function: Func): Any =
TotalTransformations.viaInferred[Source, Func](source, function)
transparent inline def intoVia[Func](inline function: Func): Any =
AppliedViaBuilder.create(source, function)
}
extension [F[+x], Source](value: Source)(using F: Mode[F]) {
inline def fallibleTo[Dest]: F[Dest] = FallibleTransformations.between[F, Source, Dest](value, F, "transformation")
transparent inline def fallibleVia[Func](inline function: Func): F[Any] =
FallibleTransformations.viaInferred[F, Source, Func](value, function, F)
}