[Haskell-cafe] Re: Type classes question

2008-10-08 Thread Roly Perera
Ryan Ingram ryani.spam at gmail.com writes: [...] Here's another possible solution: newtype AsFunctor s a = AF { fstream :: (s a) } instance (Stream f) = Functor (AsFunctor f) where fmap f (AF s) = AF (fmapStreamDefault f s) Now to use fmap you wrap in AF and unwrap with

Re: [Haskell-cafe] Type classes question

2008-10-07 Thread Ryan Ingram
On Tue, Oct 7, 2008 at 1:13 PM, Roly Perera [EMAIL PROTECTED] wrote: Hi, I'm reasonably well versed in Haskell but fairly new to defining type classes. In particular I don't really understand how to arrange for all instances of X to also be instances of Y. It's quite possibly that my

[Haskell-cafe] Type classes question

2008-10-07 Thread Roly Perera
Hi, I'm reasonably well versed in Haskell but fairly new to defining type classes. In particular I don't really understand how to arrange for all instances of X to also be instances of Y. It's quite possibly that my question is ill-posed, so I'll make it as concrete as possible: in the

Re: [Haskell-cafe] Type classes question

2008-10-07 Thread Bulat Ziganshin
Hello Roly, Tuesday, October 7, 2008, 4:13:25 PM, you wrote: I'm reasonably well versed in Haskell but fairly new to defining type classes. http://haskell.org/haskellwiki/OOP_vs_type_classes may be useful -- Best regards, Bulatmailto:[EMAIL PROTECTED]

Type classes question

2003-08-29 Thread Eugene Nonko
Title: Type classes question Hello, I am trying to define class Dual and few instances as follows: === class Dual a where dual :: a - a instance Dual Bool where dual = not instance (Dual a, Dual b) = Dual (a - b) where dual f = dual . f . dual instance Dual a = Dual