{-# LINE 1 "Poll.hsc" #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LINE 2 "Poll.hsc" #-} {-# LINE 4 "Poll.hsc" #-} module Poll ( toEvent ) where -- from base: import Data.Bits ( (.&.) ) import Data.Bool ( otherwise ) import Data.Eq ( (/=) ) import Data.Monoid ( mempty, mappend ) import Foreign.C.Types ( CShort ) -- from usb: -- I need to import GHC.Event or System.Event based on the version of base. -- However it's currently not possible to use cabal macros in .hsc files. -- See: http://hackage.haskell.org/trac/hackage/ticket/870 -- So I use an intermediate module that makes the choice: import Event ( Event, evtRead, evtWrite ) toEvent :: CShort -> Event toEvent e = remap (1) evtRead `mappend` {-# LINE 23 "Poll.hsc" #-} remap (4) evtWrite {-# LINE 24 "Poll.hsc" #-} where remap evt to | e .&. evt /= 0 = to | otherwise = mempty