[Haskell-cafe] Re: Type variables

Giuseppe Maggiore giuseppemag at gmail.com
Tue Mar 9 12:27:16 EST 2010


Thanks, that helped (monomorphism restriction and copointed)...

I'll see if I can come up with a more specific example!


On Tue, Mar 9, 2010 at 6:12 PM, Maciej Piechotka <uzytkownik2 at gmail.com>wrote:

> 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
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Giuseppe Maggiore
Ph.D. Student (Languages and Games)
Microsoft Student Partner
Mobile: +393319040031
Office: +390412348444
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100309/e098d8bf/attachment.html


More information about the Haskell-Cafe mailing list