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 ---------

Attachment: pgptjsuHVMKMf.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to