Fergus Henderson wrote:
On 17-Feb-1999, Lennart Augustsson [EMAIL PROTECTED] wrote:
What's wrong with
class Foo a b where
write :: a - b - IO ()
?
Well, it's not Haskell. :-)
Oh, good point blush. I forgot about that.
Please take my mail above as a vote in favour of including
multi-parameter type classes in Haskell-2! ;-)
Actually, that's very close to what I have implemented in Real Life. I'm
not sure of what the semantic meaning of "multi-parameter type classes"
is, but an example of what I actually have defined is something like:
class Foo a where
write :: a b - b - IO ()
In which case I define instances such as
data Fooable b = Fooable (IORef b)
instance Foo Fooable where
write (Fooable ref) val = ...
Anyway, back to the point. I'm not sure if such a concept has yet been
given a name, but it sure would eliminate a lot of headaches if Haskell
provided something like type patterns. Example:
class Foo a where
write :: a - b - IO ()
instance Foo TextEntry where
write te (val :: String) = setText te val
write te (val :: Show a = a) = setText te $ show val
write te val = ioError ...
Right now, the only way I can figure out how to do this is to define
something like
data Show a = WriteVal a b = WVString String | WVShow a | WVElse b
but this is not easily extendable for ad-hoc situations. (I haven't even
verified if the above statement will really work. I have only done the
MaybePoly)
- Michael Hobbs