-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from susliko/enum-derivation
Scala 3. Derivation for enums. Better derivation for sealed traits
- Loading branch information
Showing
12 changed files
with
743 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
modules/core/src/main/scala-3/ru/tinkoff/phobos/derivation/LazySummon.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.tinkoff.phobos.derivation | ||
|
||
/** Defining givens of such type in companion objects of ElementEncoder and ElementDecoder allows to summon instances of | ||
* these typeclasses for every child of a sum type (sealed trait or enum), e.g. like this: | ||
* {{{ | ||
* summonAll[Tuple.Map[m.MirroredElemTypes, [t] =>> LazySummon[TC, t]]] | ||
* }}} | ||
* while safeguards against automatical derivation for all types without explicit `derives` clause or | ||
* `deriveElementEncoder`/`deriveElementDecoder` calls. | ||
*/ | ||
trait LazySummon[TC[_], A]: | ||
def instance: TC[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.