On 11-04-27 05:44 PM, serialhex wrote:
in ruby they use what some call "duck typing"  if it looks
like a duck and quacks like a duck... it's a duck.

Python and Javascript also do duck typing.

Haskell does Functor typing. A Functor is something that provides an "fmap" method. List does it, so you can do

  fmap not [True,False]

Maybe also does it, so you can also do

  fmap not (Just False)

Your own data type could also do it. Suppose your data type is (binary tree)

  data BT a = Z | Y a (BT a) (BT a)
    deriving Show

then you add

  instance Functor BT where
    fmap f Z = Z
    fmap f (Y x t0 t1) = Y (f x) (fmap f t0) (fmap f t1)

then BT provides an "fmap" method too, and so you can also do

  fmap not (Y True (Y False Z Z) Z)

If it fmaps like a Functor, it is a Functor. That is Functor typing.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to