
On Tue, 2010-03-09 at 15:50 +0100, Giuseppe Maggiore wrote:
class (CNum n, HasField n (a -> (b,rec a)) l, Convert rec) => HasMethod n l a b rec where
(..!) :: l -> n -> (a -> (b,a))
instance (CNum n, HasField n (a -> (b,rec a)) l, Convert rec) => HasMethod n l a b rec where
l ..! n =
let m = l .! n
in (\x ->
let (y,v) = m x
in (y,convert v))
i think you have in mind something like: import Control.Arrow (..!) :: (CNum n, HasField n (a -> (b,rec a)) l, Convert rec) => l -> n -> (a -> (b,a)) l ..! n = second convert . (l .! n) 1. I don't see a point of creating class. I mean you provide a wildcard implementation - why not provide just a method? 2. I'm afraid that it might be monomorphism restriction. But I'm not sure. 3. Without code I can hardly test the problems ;) I can write what I _think_ code would look like. Regards PS. I would be grateful for ASCII-only posts: http://www.asciiribbon.org/ PPS. convert looks strangly similar to copointed: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/...