Created
April 13, 2021 06:55
-
-
Save phdoerfler/74a25b79ceeda9408ddd015d486cda12 to your computer and use it in GitHub Desktop.
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
{ | |
"Case class tuple codec": { | |
"prefix": "scircetuple", | |
"body": [ | |
"import io.circe._", | |
"case class ${1:MyCaseClass}(${2:_1}: ${3:Double}, ${4:_2}: ${5:String})", | |
"object ${1} {", | |
" implicit val codec: Codec[${1}] = Codec.from(", | |
" implicitly[Decoder[(${3}, ${5})]].map((${1}.apply _).tupled),", | |
" implicitly[Encoder[(${3}, ${5})]].contramap(r => (r.${2}, r.${4}))", | |
" )", | |
"}" | |
], | |
"description": "Creates a case class and codec for dealing with tuples in circe, AKA arrays with mixed types" | |
}, | |
"Case class tuple codec 2": { | |
"prefix": "scircetuple", | |
"body": [ | |
"import io.circe._", | |
"case class ${1:MyCaseClass}(${2:_1}: ${3:Double}, ${4:_2}: ${5:String})", | |
"object ${1} {", | |
" implicit val codec: Codec[${1}] = Codec.from(", | |
" implicitly[Decoder[(${3}, ${5})]].map((${1}.apply _).tupled),", | |
" implicitly[Encoder[(${3}, ${5})]].contramap(r => ${1}.unapply(r).get)", | |
" )", | |
"}" | |
], | |
"description": "Creates a case class and codec for dealing with tuples in circe, AKA arrays with mixed types" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment