I was inspired by George Pollard&#39;s <a href="http://www.haskell.org/pipermail/haskell-cafe/2009-July/063981.html">post</a> at haskell-cafe and tried to implement the non-polymorphic Functor class ( I named it Functor&#39; ). I changed some names and added reasonable constraints.<br>
<br>    type family NewPt f a <br>    class Functor&#39; f where<br>        type Point f<br>        map ∷ (a ~ Point f, b ~ Point g, g ~ NewPt f b, Functor&#39; g) ⇒ (a → b) → f → g<br><br>I would like to be able to write:<br>
<br>    type OldPt f = NewPt f (Point f)<br>    class (f ~ OldPt f) ⇒ Functor&#39; f ...<br><br>but ghc says it&#39;s not implemented yet (version 6.12.1). However, it&#39;s not the main problem.<br><br>Now I can write some instances:<br>
<br>    type instance NewPt [a] b = [b]<br>    instance Functor&#39; [a] where<br>      type Point [a] = a<br>      map = fmap<br><br>    type instance NewPt ByteString a = ByteString<br>    instance Functor&#39; ByteString where<br>
      type Point ByteString = Word8<br>      map = BS.map<br><br>But I can&#39;t write instance for Set:<br><br>    type instance NewPt (Set a) b = Set b <br>    instance Ord a ⇒ Functor&#39; (Set a) where<br>      type Point (Set a) = a<br>
      map = Set.map<br><br>ghci  complains: Could not deduce (Ord a1) from the context (g ~ NewPt (Set a) a1, a1 ~ Point g, Functor&#39; g)<br>  arising from a use of `Set.map&#39; at ...<br><br>The type of Set.map is<br>
<br>    Set.map :: (Ord a, Ord b) =&gt; (a -&gt; b) -&gt; Set a -&gt; Set b<br><br>(Ord a) is in the instance context, and what about b? Type of map for Set instance would be:<br> <br>original:<br>    map ∷ (a ~ Point f, b ~ Point g, g ~ NewPt f b, Functor&#39; g) ⇒ (a → b) → f → g<br>
<br>substitute: f → Set a, g → Set b<br>    map :: Functor&#39; (Set b) ⇒ (a →b) →Set a →Set b<br><br>(Ord b) must be deduced from (Functor (Set b)) but it doesn&#39;t. I don&#39;t know whether it&#39;s my mistake somewhere or ghc problem.<br>
<br>(Sorry for my English, it&#39;s not perfect). <br>-- <br>All the best,<br>Alexey<br><br>