Skip to content

Commit

Permalink
builder.build
Browse files Browse the repository at this point in the history
  • Loading branch information
prange committed Jun 3, 2019
1 parent 8253572 commit 86d7ed2
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ data class JsonEndec<A>(val encoder:JsonEncoder<A>, val decoder: JsonDecoder<A>)

data class EndecBuilder<OBJ,C,REST>(val encoder:JsonObjectBuilder<OBJ,REST>, val decoder: JsonDecoder<C>)

fun <A> EndecBuilder<A,A,*>.build() =
JsonEndec(this.encoder,this.decoder)

fun <OBJ,FIRST,REST,TAIL:HList> EndecBuilder<OBJ,(FIRST)->REST,HCons<FIRST,TAIL>>
.field(name:String,endec:JsonEndec<FIRST>):EndecBuilder<OBJ,REST,TAIL> =
EndecBuilder(encoder.field(name,endec.encoder),decoder.field(name,endec.decoder))
Expand Down

0 comments on commit 86d7ed2

Please sign in to comment.