[Haskell-cafe] Deepest polymorphic functor

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Jul 31 03:07:12 EDT 2009


Hello Eduard,

Friday, July 31, 2009, 10:26:08 AM, you wrote:

>>> instance Num a => Num [a] where ...

> But why then the following snippet doesn't cause ambiguity:

> deep_fmap (++"a") "b"  // -> "ba"
> deep_fmap (++"a") ["b"]  // -> ["ba"]
> deep_fmap (++"a") [["b"]]  // -> [["ba"]]

because it doesn't involve any instances. if you will declare

class Appendable a where
  (++) :: a -> a -> a

instance Appendable String ...
instance Appendable a => Appendable [a] ...

instance IsString [a] ...
  -- class IsString, like class Num, defines conversion rules for string constants


you will get into the same trouble


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list