Permalink
Browse files

Add Event module

In Poll 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 the intermediate module Event that makes the choice.
  • Loading branch information...
basvandijk committed Aug 11, 2011
1 parent fc0666c commit be6b44e7939a3468abc32647be22d6847a27ca3f
Showing with 18 additions and 8 deletions.
  1. +9 −0 Event.hs
  2. +7 −6 Poll.hsc
  3. +2 −2 usb.cabal
View
@@ -0,0 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude, CPP #-}
+
+module Event ( Event, evtRead, evtWrite ) where
+
+#if MIN_VERSION_base(4,4,0)
+import GHC.Event ( Event, evtRead, evtWrite )
+#else
+import System.Event ( Event, evtRead, evtWrite )
+#endif
View
@@ -10,15 +10,16 @@ import Data.Bool ( otherwise )
import Data.Monoid ( mempty, mappend )
import Foreign.C.Types ( CShort )
-#if MIN_VERSION_base(4,4,0)
-import GHC.Event ( Event, evtRead, evtWrite )
-#else
-import System.Event ( Event, evtRead, evtWrite )
-#endif
-
-- from base-unicode-symbols:
import Data.Eq.Unicode ( (≢) )
+-- 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 (#const POLLIN) evtRead `mappend`
remap (#const POLLOUT) evtWrite
View
@@ -104,7 +104,7 @@ Library
if impl(ghc>7) && !os(windows)
cpp-options: -DHAS_EVENT_MANAGER
- other-modules: Poll, Timeval
+ other-modules: Poll, Event, Timeval
build-depends: containers >= 0.1 && < 0.5
executable example
@@ -125,5 +125,5 @@ executable example
if impl(ghc>7) && !os(windows)
cpp-options: -DHAS_EVENT_MANAGER
- other-modules: Poll, Timeval
+ other-modules: Poll, Event, Timeval
build-depends: containers >= 0.1 && < 0.5

0 comments on commit be6b44e

Please sign in to comment.