-
Notifications
You must be signed in to change notification settings - Fork 9
/
Case.scala
95 lines (72 loc) 路 3.79 KB
/
Case.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package io.github.arainko.ducktape
import scala.annotation.compileTimeOnly
opaque type Case[A, B] <: Case.Fallible[Nothing, A, B] = Case.Fallible[Nothing, A, B]
object Case {
opaque type Fallible[+F[x], A, B] = Unit
@compileTimeOnly("Case.fallibleConst is only useable as a case configuration for transformations")
def fallibleConst[F[+x], A, B, SourceTpe, DestTpe](
selector: Selector ?=> A => SourceTpe,
value: F[DestTpe]
): Case.Fallible[F, A, B] = ???
@compileTimeOnly("Case.fallibleConst is only useable as a case configuration for transformations")
def fallibleComputed[F[+x], A, B, SourceTpe, DestTpe](
selector: Selector ?=> A => SourceTpe,
function: SourceTpe => F[DestTpe]
): Case.Fallible[F, A, B] = ???
@compileTimeOnly("Case.const is only useable as a case configuration for transformations")
def const[A, B, SourceTpe, DestTpe](selector: Selector ?=> A => SourceTpe, value: DestTpe): Case[A, B] = ???
@compileTimeOnly("Case.computed is only useable as a case configuration for transformations")
def computed[A, B, SourceTpe, DestTpe](selector: Selector ?=> A => SourceTpe, function: SourceTpe => DestTpe): Case[A, B] = ???
@deprecated(
message = "Use the variant that accepts a path selector instead (Case.const(_.at[SourceSubtype], ...))",
since = "ducktape 0.2.0-M1"
)
@compileTimeOnly("'Case.const' needs to be erased from the AST with a macro.")
def const[SourceSubtype]: Case.Const[SourceSubtype] = ???
opaque type Const[SourceSubtype] = Unit
object Const {
extension [SourceSubtype](inst: Const[SourceSubtype]) {
@compileTimeOnly("'Case.const' needs to be erased from the AST with a macro.")
def apply[Source >: SourceSubtype, Dest](const: Dest): Case[Source, Dest] = ???
}
}
@deprecated(
message = "Use the variant that accepts a path selector instead (Case.computed(_.at[SourceSubtype], ...))",
since = "ducktape 0.2.0-M1"
)
@compileTimeOnly("Case.computed is only useable as a case configuration for transformations")
def computed[SourceSubtype]: Case.Computed[SourceSubtype] = ???
opaque type Computed[SourceSubtype] = Unit
object Computed {
extension [SourceSubtype](inst: Computed[SourceSubtype]) {
@compileTimeOnly("Case.computed is only useable as a case configuration for transformations")
def apply[Source >: SourceSubtype, Dest](f: SourceSubtype => Dest): Case[Source, Dest] = ???
}
}
@deprecated(
message = "Use the variant that accepts a path selector instead (Case.fallibleConst(_.at[SourceSubtype], ...))",
since = "ducktape 0.2.0-M3"
)
@compileTimeOnly("Case.fallibleConst is only useable as a case configuration for transformations")
def fallibleConst[SourceSubtype]: Case.FallibleConst[SourceSubtype] = ???
opaque type FallibleConst[SourceSubtype] = Unit
object FallibleConst {
extension [SourceSubtype](inst: FallibleConst[SourceSubtype]) {
@compileTimeOnly("'Case.fallibleConst' needs to be erased from the AST with a macro.")
def apply[F[+x], Source, Dest](const: F[Dest]): Case.Fallible[F, Source, Dest] = ???
}
}
@deprecated(
message = "Use the variant that accepts a path selector instead (Case.fallibleComputed(_.at[SourceSubtype], ...))",
since = "ducktape 0.2.0-M3"
)
@compileTimeOnly("Case.fallibleComputed is only useable as a case configuration for transformations")
def fallibleComputed[SourceSubtype]: Case.FallibleComputed[SourceSubtype] = ???
opaque type FallibleComputed[SourceSubtype] = Unit
object FallibleComputed {
extension [SourceSubtype](inst: FallibleComputed[SourceSubtype]) {
@compileTimeOnly("Case.fallibleComputed is only useable as a case configuration for transformations")
def apply[F[+x], Source, Dest](const: SourceSubtype => F[Dest]): Case.Fallible[F, Source, Dest] = ???
}
}
}