[Haskell-cafe] Class Interfaces in OOHaskell?
saynte at gmail.com
Fri Jul 6 11:58:54 EDT 2007
Looking at the OOHaskell black (grey?) magic, and wondering if there
would be an interesting way to construct class interfaces using the
I'm trying to do it as so (assume relevant types/proxies declared):
type FigureInter = Record ( Draw :=: IO ()
figure self = do
_ = narrow self :: FigureInter
abstrFigure self = do
super <- figure self
visible <- newIORef True
$ setVisible .=. (\b -> writeIORef visible b)
.*. isVisible .=. readIORef visible
.*. draw .=. return ()
but ghci complains (you know how it likes to complain), with
Couldn't match expected type `Record t2'
against inferred type `F (Proxy Draw) (m ())'
In the second argument of `(.*.)', namely `draw .=. (return ())'
In the second argument of `(.*.)', namely
`(isVisible .=. (readIORef visible)) .*. (draw .=. (return ()))'
In the first argument of `(.<.)', namely
`(setVisible .=. (\ b -> writeIORef visible b))
((isVisible .=. (readIORef visible)) .*. (draw .=. (return ())))'
Anyone have any tips they care to share? :)
More information about the Haskell-Cafe