Last active
April 28, 2017 12:48
-
-
Save divarvel/d8de31cdc8d1107e4c06 to your computer and use it in GitHub Desktop.
Anorm parser derivation
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
> compile | |
[info] Compiling 1 Scala source to /mnt/data/projects/perso/pg-entities/target/scala-2.11/classes... | |
[error] /mnt/data/projects/perso/pg-entities/src/main/scala/pgentity/automagic/ParserDerivation.scala:59: could not find implicit value for parameter subtypeUnifier: shapeless.ops.hlist.SubtypeUnifier[keys.Out,Symbol] | |
[error] val parsers = functionList zipApply keys().unifySubtypes[Symbol] | |
[error] ^ | |
[error] one error found | |
[error] (compile:compile) Compilation failed | |
[error] Total time: 1 s, completed 28-Jan-2016 19:35:50 |
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
def generateParser[Entity, LHL <: HList, HL <: HList]( | |
implicit labelledGen: LabelledGeneric.Aux[Entity, LHL], | |
gen: Generic.Aux[Entity, HL], | |
keys: Keys[LHL], | |
toParser: FieldToParser[LHL]) = { | |
val functionList = FieldToParser[labelledGen.Repr].apply() | |
val parsers = functionList zipApply keys().unifySubtypes[Symbol] | |
object composeParsers extends Poly2 { | |
implicit def merge[A, B] = at[RowParser[A], RowParser[B]]((fp: RowParser[A], parseAcc: RowParser[B]) => fp ~ parseAcc) | |
} | |
parsers.tail.foldLeft(parsers.head)(composeParsers).map(x => gen.from(hlist(x))) | |
} |
Hi, I'm trying to make this work. Did you manage to unify KOut and keys.Out ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks to me like
KOut
will equalkeys.Out
in @jto's fragment.