<commit_before>package io.rout.generic.decoding


import shapeless.labelled._
import shapeless._
import scala.reflect.ClassTag
import scala.language.implicitConversions
import scala.language.higherKinds
import com.twitter.finagle.http.Cookie
import io.rout._

/**
 * A type classes empowering a generic derivation of [[io.rout.ReqRead]]s from query string params.
 */

trait FromParams[L <: HList] {
  def reader: ReqRead[L]
}

object FromParamsExtract extends Poly1 {

   case class FromMap[K,V](key: K, value: V){
    def toMap = Map[K,V](key -> value)
  }

  implicit val cookieRR: Case.Aux[String,ReqRead[Cookie]] = at[String](key => cookie(key))

  implicit val cookieRROption: Case.Aux[String,ReqRead[Option[Cookie]]] = at[String](key => cookieOption(key))

  implicit def nested[Repr <: HList,V](implicit
    gen: LabelledGeneric.Aux[V, Repr],
    fp:  Lazy[FromParams[Repr]]
  ): Case.Aux[String,ReqRead[V]] = at[String]{ key =>
    derive[V].fromParams
  }<commit_msg>accept all params for key and value<commit_after>package io.rout.generic.decoding


import shapeless.labelled._
import shapeless._

import scala.reflect.ClassTag
import scala.language.implicitConversions
import scala.language.higherKinds
import com.twitter.finagle.http.Cookie
import io.rout._

/**
 * A type classes empowering a generic derivation of [[io.rout.ReqRead]]s from query string params.
 */

trait FromParams[L <: HList] {
  def reader: ReqRead[L]
}

object FromParamsExtract extends Poly1 {

   case class FromMap[K,V](key: Seq[K], value: Seq[V]){
    def toMap = (key zip value).toMap
  }

  implicit val cookieRR: Case.Aux[String,ReqRead[Cookie]] = at[String](key => cookie(key))

  implicit val cookieRROption: Case.Aux[String,ReqRead[Option[Cookie]]] = at[String](key => cookieOption(key))

  implicit def nested[Repr <: HList,V](implicit
    gen: LabelledGeneric.Aux[V, Repr],
    fp:  Lazy[FromParams[Repr]]
  ): Case.Aux[String,ReqRead[V]] = at[String]{ key =>
    derive[V].fromParams
  }
{'fraction_non_alphanumeric': 0.13192346424974824, 'fraction_numerical': 0.0010070493454179255, 'mean_word_length': 4.844117647058823, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2356307', 'n_tokens_mistral': 696, 'n_tokens_neox': 682, 'n_words': 155}