title: Defining Haskell FixF in scala
body: <p>So comonad.com has an interesting series of articles on working with applicatives and I've been trying to bring what I can to scala (for fun, and to learn). So, haskell defines FixF –</p>
  
  <pre><code>newtype FixF f a = FixF (f (FixF f) a)
  </code></pre>
  
  <p>it is written ,"<code>FixF</code> is of kind <code>((* -&gt; *) -&gt; * -&gt; *) -&gt; * -&gt; *)</code>. It takes the fixpoint of a "second-order Functor" (a Functor that sends a Functor to another Functor, i.e. an endofunctor on the functor category of hask), to recover a standard "first order Functor" back out."</p>
  
  <pre><code>kinds classify types
  *                   type  A
  * -&gt; *              type F[_]
  * -&gt; * -&gt; *         type F[_,_]
  ((* -&gt; *) -&gt; *)     type F[F'[_]]
  ((* -&gt; *) -&gt;* -&gt; *) type F[F'[_], A] 
  </code></pre>
  
  <p>Now I've seen this </p>
  
  <pre><code>case class Fix[F[_]](out: F[Fix[F]])
  // ((* -&gt; *) -&gt; * )
  </code></pre>
  
  <p>and this </p>
  
  <pre><code>case class BFixF[F[_,_], A](out: F[A, BFixF[F,A]])
  </code></pre>
  
  <p>So it's not the first one Fix (wrong kinds) Is it the second? I don't the think the kinds are right</p>
  
  <pre><code>BFixF :: ((* -&gt; * -&gt; * ) -&gt; * -&gt; *) ?
  </code></pre>
  
  <p>is it -</p>
  
  <pre><code>    // edit as of this morning it is really not this
      class FixF[F[_[_], _], A] :: ((* -&gt; *) -&gt; * -&gt; *) -&gt; *)
  </code></pre>
  
  <p>is it ?</p>
  
  <pre><code>    case class FixF'[F[_], A](run: F[Fix[F, A]]) 
  </code></pre>
  
  <p>if so I'd love to see the proper definition and functor </p>
  
  <pre><code> case class FixF[F[_], A] (out: F[Fix[F, A]])
  
   trait FixFFunctor[F[_]: Functor] extends Functor[({type l[x] = FixF[F, x]})#l] {
  
     def map[A, B](f: A =&gt; B): FixF[F, A] =&gt; FixF[F, B] = ???
  
   }
  </code></pre>
  
  <p>now bonus question, can someone define the applicative ?</p>