{-# LINE 1 "src/Poll.hsc" #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Poll ( toEvent ) where
import Data.Bits ( (.&.) )
import Data.Bool ( otherwise )
import Data.Eq ( (/=) )
import Data.Monoid ( mempty, mappend )
import Foreign.C.Types ( CShort )
import Event ( Event, evtRead, evtWrite )
toEvent :: CShort -> Event
toEvent e = remap (1) evtRead `mappend`
{-# LINE 23 "src/Poll.hsc" #-}
remap (4) evtWrite
{-# LINE 24 "src/Poll.hsc" #-}
where
remap evt to
| e .&. evt /= 0 = to
| otherwise = mempty