title: How can scalaz' Functor be given a higher-kinded type with a context bound?
body: <p>I want to define a Functor instances for the following classes:</p>
  
  <pre><code>class RequiresManifest[A: Manifest] {
    def value: A
  }
  
  class RequiresAnyRef[A &lt;: AnyRef] {
    def value: A
  }
  
  class RequiresBothManifestAndAnyRef[A &lt;: AnyRef: Manifest] {
    def value: A
  }
  </code></pre>
  
  <p>Is this possible ? Alternatively can a 'BoundedFunctor trait be defined ? something like this:</p>
  
  <pre><code>trait BoundedFunctor[F[_], Bound[_]] {
    def fmap[A: Bound, B: Bound](r: F[A], f: A =&gt; B): F[B]
  }
  </code></pre>
  
  <p>Here's my motivating example: How can I defined a Functor for the class TypedConverter.</p>
  
  <pre><code>import com.thoughtworks.xstream.converters.Converter
  
  abstract class TypedConverter[A &lt;: AnyRef: Manifest] extends Converter { 
    final def canConvert(klass: Class[_]) = 
      manifest[A].erasure.isAssignableFrom(klass)
  
    final def marshal(value: AnyRef, writer: HierarchicalStreamWriter, 
                      context: MarshallingContext) =
      typedMarshal(value.asInstanceOf[A], writer, context)
  
    final def unmarshal(reader: HierarchicalStreamReader, 
                        context: UnmarshallingContext) = 
      typedUnmarshal(reader, context)
  
    def typedMarshal(value: A, writer: HierarchicalStreamWriter, 
                     context: MarshallingContext): Unit
  
    def typedUnmarshal(reader: HierarchicalStreamReader, 
                       context: UnmarshallingContext): A
  }
  </code></pre>
  
  <p>This higher-kinded type has two constraints on its type parameter, first Manifest because that's used in the implementation of 'canConvert', second AnyRef because unmarshal requires an Object.</p>
  
  <p>Actually I'm trying to create an InvariantFunctor, but Functor will do to start with.</p>