[Haskell-cafe] Inheritance without OOHaskell
Georg Martius
mai99dgf at studserv.uni-leipzig.de
Sat Jan 14 16:00:51 EST 2006
Hi,
I would like to add some minor improvement on usability of the existential
type Connection proposed by Bulat.
> data Connection = forall c . (IsConnection c) => Conn c
The thing is that you usually have functions like
send :: (isConnection c) => c -> String -> IO()
or whatever. In order to be able to feed a variable of type Connection into
functions like send it is handy to define
instance IsConnection Connection where
foo (Conn c) = foo c
setFoo bar (Conn c) = Conn $ setFoo bar c
...
which delegates functions "into" the item inside the exitential wrapper.
Cheers,
Georg
--
---- Georg Martius, Tel: (+49 34297) 89434 ----
------- http://www.flexman.homeip.net ---------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060114/2bb72604/attachment.bin
More information about the Haskell-Cafe
mailing list