<commit_before>trait LowPriorityPolyFunCases {
  import HList._
  
  type Id[T] = T
  type Const[C] = {
    type λ[T] = C
  }

  type Tagged[T] = { type Tag = T }
  type @@[T, U] = T with Tagged[U]
  
  def tag[T] = new {
    def apply[U](u : U) : U with Tagged[T] = u.asInstanceOf[U @@ T]
  }
  
  trait HRFn
  
  trait ~>[F[_], G[_]] {
    type λ[T] = (F[T] => G[T]) @@ this.type
    def λ[T](c : F[T] => G[T]) = tag[this.type](c)
    def taggedDflt[T] = λ[T](dflt)
    
    def apply[T](f : F[T])(implicit c : (F[T] => G[T]) @@ this.type = taggedDflt[T]) : G[T] = c(f)
    def dflt[T](f : F[T]) : G[T]
  }

  implicit def univInst1[F[_], G[_], T](h : F ~> G)
    (implicit c : (F[T] => G[T]) @@ h.type = h.taggedDflt[T]) : h.λ[T] = c
    
  implicit def univInst2[F[_], G, T](h : F ~> Const[G]#λ)
    (implicit c : (F[T] => G) @@ h.type = h.taggedDflt[T]) : h.λ[T] = c
}

object PolyFunCases extends LowPriorityPolyFunCases {
}
<commit_msg>Moved definitions up to HRFn allowing simplification of univInst*.<commit_after>trait LowPriorityPolyFunCases {
  import HList._
  
  type Id[T] = T
  type Const[C] = {
    type λ[T] = C
  }

  type Tagged[T] = { type Tag = T }
  type @@[T, U] = T with Tagged[U]
  
  def tag[T] = new {
    def apply[U](u : U) : U with Tagged[T] = u.asInstanceOf[U @@ T]
  }
  
  trait HRFn {
    type F[_]
    type G[_]

    type Case[T] = F[T] => G[T]
    type λ[T] = Case[T] @@ this.type
    def λ[T](c : Case[T]) = tag[this.type](c)

    def dflt[T] : λ[T] = λ[T](dflt(_))
    def dflt[T](f : F[T]) : G[T]

    def apply[T](f : F[T])(implicit c : λ[T] = dflt[T]) : G[T] = c(f)
  }
  
  trait ~>[F0[_], G0[_]] extends HRFn {
    type F[X] = F0[X]
    type G[X] = G0[X]
  }

  implicit def univInst[HF <: HRFn, T](h : HF)(implicit c : h.λ[T] = h.dflt[T]) : h.λ[T] = c
}

object PolyFunCases extends LowPriorityPolyFunCases {
}

{'fraction_non_alphanumeric': 0.2095905172413793, 'fraction_numerical': 0.003232758620689655, 'mean_word_length': 2.6845238095238093, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 13, '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': '1422878', 'n_tokens_mistral': 904, 'n_tokens_neox': 878, 'n_words': 202}