[Haskell-cafe] Re: Type variables

Maciej Piechotka uzytkownik2 at gmail.com
Tue Mar 9 12:12:40 EST 2010


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/Control-Functor-Pointed.html#t%3ACopointed


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100309/7241ed4d/attachment.bin


More information about the Haskell-Cafe mailing list