
14 Jan
2006
14 Jan
'06
4 p.m.
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 ---------