Skip to content
This repository
Browse code

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...
commit be6b44e7939a3468abc32647be22d6847a27ca3f 1 parent fc0666c
Bas van Dijk authored August 11, 2011
9  Event.hs
... ...
@@ -0,0 +1,9 @@
  1
+{-# LANGUAGE NoImplicitPrelude, CPP #-}
  2
+
  3
+module Event ( Event, evtRead, evtWrite ) where
  4
+
  5
+#if MIN_VERSION_base(4,4,0)
  6
+import GHC.Event       ( Event, evtRead, evtWrite )
  7
+#else
  8
+import System.Event    ( Event, evtRead, evtWrite )
  9
+#endif
13  Poll.hsc
@@ -10,15 +10,16 @@ import Data.Bool       ( otherwise )
10 10
 import Data.Monoid     ( mempty, mappend )
11 11
 import Foreign.C.Types ( CShort )
12 12
 
13  
-#if MIN_VERSION_base(4,4,0)
14  
-import GHC.Event       ( Event, evtRead, evtWrite )
15  
-#else
16  
-import System.Event    ( Event, evtRead, evtWrite )
17  
-#endif
18  
-
19 13
 -- from base-unicode-symbols:
20 14
 import Data.Eq.Unicode ( (≢) )
21 15
 
  16
+-- from usb:
  17
+-- I need to import GHC.Event or System.Event based on the version of base.
  18
+-- However it's currently not possible to use cabal macros in .hsc files.
  19
+-- See: http://hackage.haskell.org/trac/hackage/ticket/870
  20
+-- So I use an intermediate module that makes the choice:
  21
+import Event ( Event, evtRead, evtWrite )
  22
+
22 23
 toEvent ∷ CShort → Event
23 24
 toEvent e = remap (#const POLLIN)  evtRead `mappend`
24 25
             remap (#const POLLOUT) evtWrite
4  usb.cabal
@@ -104,7 +104,7 @@ Library
104 104
 
105 105
   if impl(ghc>7) && !os(windows)
106 106
     cpp-options: -DHAS_EVENT_MANAGER
107  
-    other-modules: Poll, Timeval
  107
+    other-modules: Poll, Event, Timeval
108 108
     build-depends: containers >= 0.1 && < 0.5
109 109
 
110 110
 executable example
@@ -125,5 +125,5 @@ executable example
125 125
 
126 126
   if impl(ghc>7) && !os(windows)
127 127
     cpp-options: -DHAS_EVENT_MANAGER
128  
-    other-modules: Poll, Timeval
  128
+    other-modules: Poll, Event, Timeval
129 129
     build-depends: containers >= 0.1 && < 0.5

0 notes on commit be6b44e

Please sign in to comment.
Something went wrong with that request. Please try again.