Skip to content

Instantly share code, notes, and snippets.

@wfaler
Last active June 29, 2017 09:13
Show Gist options
  • Save wfaler/bb254253f7bb0ed1b9fffb97a3ff582c to your computer and use it in GitHub Desktop.
Save wfaler/bb254253f7bb0ed1b9fffb97a3ff582c to your computer and use it in GitHub Desktop.
Finding out type of prepend.Out
case class Record[A](userId: UUID, createdAt: LocalDateTime, version: Long, data: A)
type MetaData = UUID :: LocalDateTime :: Long :: HNil
def length[R <: HList](record: Record[A])
(implicit gen: Generic.Aux[A, R],
prepend: Prepend[R, MetaData]) = {
val data = gen.to(record.data)
val meta = record.userId :: record.createdAt :: record.version :: HNil
val toWrite = data ::: meta
// next line fails, missing Length[prepend.Out], but prepend.Out cannot be used in the implicit arg list.
// What should be an alternate, but valid type signature of prepend.Out?
val natLen = toWrite.length
// Not gotten here, but probably yet another signature issue in waiting.
Nat.toInt(natLen)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment