{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-} module GLDriver ( Driver(..) , Event , SomeEvent(..) , QuitEvent(..) , fromEvent ) where import Data.Typeable class Driver a where initialized :: a -> Bool initGL :: a -> IO a deinitGL :: a -> IO () nextEvent :: a -> IO (Maybe SomeEvent) class Typeable a => Event a data SomeEvent = forall a. Event a => SomeEvent a fromEvent :: Event a => SomeEvent -> Maybe a fromEvent (SomeEvent a) = cast a data QuitEvent = QuitEvent deriving Typeable instance Event QuitEvent