Skip to content

Commit c948b92

Browse files
committed
[base] In docs, group typeclass instances by context
1 parent 414ef60 commit c948b92

File tree

4 files changed

+342
-10
lines changed

4 files changed

+342
-10
lines changed

Base/src/main/scala/typeclass/Eithered.scala

+97-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,22 @@ trait BiEithered[Ctx, Expr[+_], A, B, Z]
6969
/**
7070
* Predefined implicit implementations of Eithered
7171
* and methods to create new Eithereds
72+
*
73+
* @groupname Support Support
74+
* @groupprio Support 100
75+
* @groupname AnyContext Any Context
76+
* @groupprio AnyContext 1000
77+
* @groupname QuotedContext Quotes Context
78+
* @groupprio QuotedContext 1010
79+
* @groupname MacroContext Macro Context
80+
* @groupprio MacroContext 1020
81+
* @groupname IdContext Identity Context
82+
* @groupprio IdContext 1030
7283
*/
7384
object Eithered extends LowPrioEithered {
7485
/**
7586
* Constructs an `Eithered` from a set of functions corresponding to each of Eithered's methods
87+
* @group Support
7688
*/
7789
def apply[Ctx, A, B, Z](leftFn:(A, Ctx) => Z, rightFn:(B, Ctx) => Z):Eithered[Ctx, A, B, Z] = {
7890
final class Apply extends Eithered[Ctx, A, B, Z] {
@@ -82,16 +94,28 @@ object Eithered extends LowPrioEithered {
8294
new Apply()
8395
}
8496

97+
/**
98+
* @group AnyContext
99+
*/
85100
@ifdef("scalaEpochVersion:2")
86101
implicit def unitUnit:Eithered[Any, Unit, Unit, Unit] = symmetric[Unit]
102+
/**
103+
* @group AnyContext
104+
*/
87105
@ifdef("scalaBinaryVersion:3")
88106
implicit def unitUnit:Eithered[Any, Unit, Unit, Unit] = Eithered.generic
89107

108+
/**
109+
* @group AnyContext
110+
*/
90111
implicit def unitGeneric[Ctx, B, Z](implicit ev:Optionally[Ctx, B, Z]):Eithered[Ctx, Unit, B, Z] =
91112
Eithered(
92113
(_:Unit, ctx) => ev.none(ctx),
93114
(value, ctx) => ev.some(value)(ctx),
94115
)
116+
/**
117+
* @group AnyContext
118+
*/
95119
implicit def genericUnit[Ctx, A, Z](implicit ev:Optionally[Ctx, A, Z]):Eithered[Ctx, A, Unit, Z] =
96120
Eithered(
97121
(value, ctx) => ev.some(value)(ctx),
@@ -100,13 +124,15 @@ object Eithered extends LowPrioEithered {
100124

101125
/**
102126
* @version 0.1.1
127+
* @group MacroContext
103128
*/
104129
@ifdef("scalaEpochVersion:2")
105130
def contextSplicePiece[Ctx <: scala.reflect.macros.blackbox.Context with Singleton, A]: Eithered[Ctx, Ctx#Expr[A], Ctx#Expr[Iterable[A]], Repeated.SplicePiece[Ctx#Expr, A]] =
106131
Eithered((value, _) => new Repeated.SplicePiece.One(value), (value, _) => new Repeated.SplicePiece.Many(value))
107132

108133
/**
109134
* @version 0.1.1
135+
* @group QuotedContext
110136
*/
111137
@ifdef("scalaBinaryVersion:3")
112138
def quotedSplicePiece[A]: Eithered[scala.quoted.Quotes, scala.quoted.Expr[A], scala.quoted.Expr[Iterable[A]], Repeated.SplicePiece[scala.quoted.Expr, A]] =
@@ -128,6 +154,7 @@ object Eithered extends LowPrioEithered {
128154
* evenOdd.interpolate(StringContext("4"), Nil) // Left(4): Either[Char, Char]
129155
* evenOdd.interpolate(StringContext("7"), Nil) // Right(7): Either[Char, Char]
130156
* ```
157+
* @group AnyContext
131158
*/
132159
def discriminatedUnion[A, B]:Eithered[Any, A, B, Either[A, B]] =
133160
Eithered(
@@ -137,6 +164,9 @@ object Eithered extends LowPrioEithered {
137164
}
138165

139166
private[typeclass] trait LowPrioEithered {
167+
/**
168+
* @group AnyContext
169+
*/
140170
@ifdef("scalaEpochVersion:2")
141171
implicit def symmetric[A]:Eithered[Any, A, A, A] = {
142172
Eithered(
@@ -152,6 +182,7 @@ private[typeclass] trait LowPrioEithered {
152182
* Since the union of a type with itself is equivalent to that same type,
153183
* if this Eithered is used for two parsers of the same type,
154184
* then the result is a parser of that type.
185+
* @group AnyContext
155186
*/
156187
@ifdef("scalaBinaryVersion:3")
157188
implicit def generic[A, B]:Eithered[Any, A, B, A | B] =
@@ -164,10 +195,22 @@ private[typeclass] trait LowPrioEithered {
164195
/**
165196
* Predefined implicit implementations of ContraEithered
166197
* and methods to create new ContraEithereds
198+
*
199+
* @groupname Support Support
200+
* @groupprio Support 100
201+
* @groupname AnyContext Any Context
202+
* @groupprio AnyContext 1000
203+
* @groupname QuotedContext Quotes Context
204+
* @groupprio QuotedContext 1010
205+
* @groupname MacroContext Macro Context
206+
* @groupprio MacroContext 1020
207+
* @groupname IdContext Identity Context
208+
* @groupprio IdContext 1030
167209
*/
168210
object ContraEithered extends LowPrioContraEithered {
169211
/**
170212
* Constructs an `ContraEithered` from a set of functions corresponding to each of ContraEithered's methods
213+
* @group Support
171214
*/
172215
def apply[Ctx, Expr[+_], A, B, Z](
173216
contraLeftFn:PartialExprFunction[Ctx, Expr, Z, A],
@@ -180,32 +223,62 @@ object ContraEithered extends LowPrioContraEithered {
180223
new Apply()
181224
}
182225

226+
/**
227+
* @group MacroContext
228+
*/
183229
@ifdef("scalaEpochVersion:2")
184230
implicit def contextUnitUnit[Ctx <: scala.reflect.macros.blackbox.Context with Singleton, A]:ContraEithered[Ctx, Ctx#Expr, Unit, Unit, Unit] = BiEithered.contextUnitUnit[Ctx]
185231

232+
/**
233+
* @group QuotedContext
234+
*/
186235
@ifdef("scalaBinaryVersion:3")
187236
implicit def quotedUnitUnit:ContraEithered[scala.quoted.Quotes, scala.quoted.Expr, Unit, Unit, Unit] = quotedSymmetric[Unit]
188237

238+
/**
239+
* @group IdContext
240+
*/
189241
implicit def idUnitUnit:ContraEithered[IdCtx, Id, Unit, Unit, Unit] = idSymmetric[Unit]
190242
}
191243

192244
private[typeclass] trait LowPrioContraEithered {
245+
/**
246+
* @group QuotedContext
247+
*/
193248
@ifdef("scalaBinaryVersion:3")
194249
implicit def quotedSymmetric[A]:ContraEithered[scala.quoted.Quotes, scala.quoted.Expr, A, A, A] = BiEithered.quotedSymmetric
195250

251+
/**
252+
* @group MacroContext
253+
*/
196254
@ifdef("scalaEpochVersion:2")
197255
implicit def contextSymmetric[Ctx <: scala.reflect.macros.blackbox.Context with Singleton, A]:ContraEithered[Ctx, Ctx#Expr, A, A, A] = BiEithered.contextSymmetric[Ctx, A]
198256

257+
/**
258+
* @group IdContext
259+
*/
199260
implicit def idSymmetric[A]:ContraEithered[IdCtx, Id, A, A, A] = BiEithered.idSymmetric
200261
}
201262

202263
/**
203264
* Predefined implicit implementations of BiEithered
204265
* and methods to create new BiEithereds
266+
*
267+
* @groupname Support Support
268+
* @groupprio Support 100
269+
* @groupname AnyContext Any Context
270+
* @groupprio AnyContext 1000
271+
* @groupname QuotedContext Quotes Context
272+
* @groupprio QuotedContext 1010
273+
* @groupname MacroContext Macro Context
274+
* @groupprio MacroContext 1020
275+
* @groupname IdContext Identity Context
276+
* @groupprio IdContext 1030
205277
*/
206278
object BiEithered extends LowPrioBiEithered {
207279
/**
208280
* Constructs an `BiEithered` from a set of functions corresponding to each of BiEithered's methods
281+
* @group Support
209282
*/
210283
def apply[Ctx, Expr[+_], A, B, Z](
211284
leftFn:(A, Ctx) => Z,
@@ -223,13 +296,21 @@ object BiEithered extends LowPrioBiEithered {
223296
new Apply()
224297
}
225298

299+
/**
300+
* @group MacroContext
301+
*/
226302
@ifdef("scalaEpochVersion:2")
227303
implicit def contextUnitUnit[Ctx <: scala.reflect.macros.blackbox.Context with Singleton]:BiEithered[Ctx, Ctx#Expr, Unit, Unit, Unit] = this.contextSymmetric[Ctx, Unit]
228304

305+
/**
306+
* @group QuotedContext
307+
*/
229308
@ifdef("scalaBinaryVersion:3")
230309
implicit def quotedUnitUnit:BiEithered[scala.quoted.Quotes, scala.quoted.Expr, Unit, Unit, Unit] = quotedSymmetric[Unit]
231310

232-
@ifdef("scalaBinaryVersion:3")
311+
/**
312+
* @group AnyContext
313+
*/
233314
implicit def eitherUnitAny[Ctx, Expr[+_], B, Z](implicit ev:BiOptionally[Ctx, Expr, B, Z]):BiEithered[Ctx, Expr, Unit, B, Z] =
234315
BiEithered[Ctx, Expr, Unit, B, Z](
235316
(_, ctx) => ev.none(ctx),
@@ -240,7 +321,9 @@ object BiEithered extends LowPrioBiEithered {
240321
),
241322
ev.contraSome,
242323
)
243-
@ifdef("scalaBinaryVersion:3")
324+
/**
325+
* @group AnyContext
326+
*/
244327
implicit def eitherAnyUnit[Ctx, Expr[+_], A, Z](implicit ev:BiOptionally[Ctx, Expr, A, Z]):BiEithered[Ctx, Expr, A, Unit, Z] =
245328
BiEithered(
246329
(value, ctx) => ev.some(value)(ctx),
@@ -252,11 +335,17 @@ object BiEithered extends LowPrioBiEithered {
252335
),
253336
)
254337

338+
/**
339+
* @group IdContext
340+
*/
255341
@ifdef("scalaBinaryVersion:3")
256342
implicit def idUnitUnit:BiEithered[IdCtx, Id, Unit, Unit, Unit] = idSymmetric[Unit]
257343
}
258344

259345
private[typeclass] trait LowPrioBiEithered {
346+
/**
347+
* @group QuotedContext
348+
*/
260349
@ifdef("scalaBinaryVersion:3")
261350
implicit def quotedSymmetric[A]:BiEithered[scala.quoted.Quotes, scala.quoted.Expr, A, A, A] = {
262351
BiEithered.apply[scala.quoted.Quotes, scala.quoted.Expr, A, A, A](
@@ -267,6 +356,9 @@ private[typeclass] trait LowPrioBiEithered {
267356
)
268357
}
269358

359+
/**
360+
* @group MacroContext
361+
*/
270362
@ifdef("scalaEpochVersion:2")
271363
implicit def contextSymmetric[Ctx <: scala.reflect.macros.blackbox.Context with Singleton, A]:BiEithered[Ctx, Ctx#Expr, A, A, A] = {
272364
BiEithered.apply[Ctx, Ctx#Expr, A, A, A](
@@ -277,6 +369,9 @@ private[typeclass] trait LowPrioBiEithered {
277369
)
278370
}
279371

372+
/**
373+
* @group IdContext
374+
*/
280375
implicit def idSymmetric[A]:BiEithered[IdCtx, Id, A, A, A] = {
281376
BiEithered.apply[IdCtx, Id, A, A, A](
282377
(value, _) => value,

0 commit comments

Comments
 (0)