>{-# OPTIONS -farrows -fglasgow-exts #-}
>module GHCbug where

>import Control.Arrow
>import Data.IORef

>class (ArrowChoice arr, ArrowApply arr) => OOArrow arr ref | ref -> arr where
>      deref	  :: arr (ref a) a

>data Method (cls :: (* -> * -> *) -> *) (a :: * -> * -> *) i o where
>     Method :: arr (i,cls arr) (o,cls arr) -> Method cls arr i o

>data MutableVar ty (arr :: * -> * -> *) where 
>     MutableVar :: (OOArrow arr ref) => ref ty -> MutableVar ty arr

>type MutableVarRef (cls :: (* -> * -> *) -> *) (arr :: * -> * -> *) ty
>		    = cls arr -> MutableVar ty arr

>instance OOArrow (Kleisli IO) IORef where
>	  deref = Kleisli readIORef

>get :: (ArrowChoice arr) => MutableVarRef cls arr ty -> Method cls arr () ty
>get fld = Method (proc ((),this) -> case fld this of
>	  (MutableVar ref) -> do val <- deref -< ref
>				 returnA -< (val,this))
