
On Thu, 2009-12-24 at 22:21 +0000, jonathanGfischoff@gmail.com wrote:
I have a class that is basically:
Hmm. Class in haskell means something similar to interface in OOP. Yes it is confusing.
data TwoLists = TL {doubleList :: [Double], intList :: [Int]}
Almost all of the operations of this type map, fold, etc on one of the lists or the other, and then return a new instance of the type.
It may be my level of English bit I cannot understend this sentence.
So I am implementing to functions dFmap, and iFmap.
What is dFmap and iFmap?
I actually would like all of the list functions, but I don't want to reimplement them.
Hmm. If you need to combine the lists I'd suggest zip/zipWith. If simply map/fold over one then just write (or similar): foldr f i . doubleList If you mean if there is class: class BiFunctor f where fmap2 :: (a -> c) -> (b -> d) -> f a b -> f c d fmap2 f g = fmap2b g . fmap2a f fmap2a :: (a -> c) -> f a b -> f c b fmap2a f = fmap2 f id fmap2b :: (b -> d) -> f a b -> f a d fmap2b = fmap2 id To write: data TwoLists a b = TwoLists [a] [b] instance BiFunctor TwoLists where fmap2 f g (TwoLists a b) = TwoLists (map f a) (map g b) then as far as I know - no - but you can always write your own. Regards