
15 Mar
2006
15 Mar
'06
3:40 a.m.
Is it possible to make a typeclass like Functor, that has a function (say "f_map"), which would work for the infinite hierarchy of types: ([],[[]],[[[]]],...)? Does that make sense? This doesn't work...
class Funct f where f_map :: (a -> b) -> f a -> f b
instance Funct [] where f_map = map
instance Funct a => Funct [a] where f_map f = map (f_map f)
main = print $ fmap (+1) [[[1,2,3]]]
...but maybe it gets the idea across? Thanks, Greg Buchholz