-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: vbergeron <[email protected]>
- Loading branch information
1 parent
c8cdbce
commit 6b969dc
Showing
2 changed files
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.github.iltotore.iron | ||
|
||
import cats.Show | ||
import _root_.doobie.{Put, Get, Meta} | ||
|
||
/** | ||
* Implicit [[Meta]]s, [[Put]]s and [[Get]]s for refined types. | ||
*/ | ||
object doobie: | ||
|
||
inline given[A, C] (using inline get: Get[A])(using Constraint[A, C], Show[A]): Get[A :| C] = | ||
get.temap[A :| C](_.refineEither) | ||
|
||
inline given[T](using m: RefinedTypeOps.Mirror[T], ev: Get[m.IronType]): Get[T] = | ||
ev.asInstanceOf[Get[T]] | ||
|
||
inline given[A, C] (using inline put: Put[A])(using Constraint[A, C], Show[A]): Put[A :| C] = | ||
put.tcontramap(identity) | ||
|
||
inline given[T](using m: RefinedTypeOps.Mirror[T], ev: Put[m.IronType]): Put[T] = | ||
ev.asInstanceOf[Put[T]] | ||
|
||
inline given[A, C] (using inline meta: Meta[A])(using Constraint[A, C], Show[A]): Meta[A :| C] = | ||
meta.tiemap[A :| C](_.refineEither)(identity) | ||
|
||
inline given[T](using m: RefinedTypeOps.Mirror[T], ev: Meta[m.IronType]): Meta[T] = | ||
ev.asInstanceOf[Meta[T]] |