[Haskell-cafe] automatically deriving Map and Filter on datatypes
etc.
Cetin Sert
cetin.sert at gmail.com
Thu Jun 5 04:03:22 EDT 2008
Hi ^_^,
Let's say we have the following data type and functions:
data Tab a = (:↺:)
| a :↓: Tab a
| Tab a :↙↘: (Tab a,Tab a)
deriving (Eq, Show, Read)
map f (:↺:) = (:↺:)
map f (a :↓: t) = f a :↓: map f t
map f (h :↙↘: (l,r)) = map f h :↙↘: (map f l, map f r)
filter p (:↺:) = (:↺:)
filter p (a :↓: t) | p a = filter p t
| otherwise = a :↓: filter p t
filter p (h :↙↘: (l,r)) = filter p h :↙↘: (filter p l, filter p r)
is it possible to automatically derive map and filter?
data Tab a = (:↺:)
| a :↓: Tab a
| Tab a :↙↘: (Tab a,Tab a)
deriving (Eq, Show, Read, Map, Filter)
If not, do you think it might be nice to have something like this in the
future?
Best Regards,
Cetin Sert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/0510637d/attachment.htm
More information about the Haskell-Cafe
mailing list