|
6 | 6 |
|
7 | 7 | #if defined(ALEX_MONAD) || defined(ALEX_MONAD_BYTESTRING)
|
8 | 8 | import Control.Applicative as App (Applicative (..))
|
9 |
| -import qualified Control.Monad (ap) |
10 | 9 | #endif
|
11 | 10 |
|
12 | 11 | import Data.Word (Word8)
|
@@ -207,26 +206,17 @@ runAlex input__ (Alex f)
|
207 | 206 | newtype Alex a = Alex { unAlex :: AlexState -> Either String (AlexState, a) }
|
208 | 207 |
|
209 | 208 | instance Functor Alex where
|
210 |
| -#ifndef ALEX_MONAD_BYTESTRING |
211 | 209 | fmap f a = Alex $ \s -> case unAlex a s of
|
212 | 210 | Left msg -> Left msg
|
213 | 211 | Right (s', a') -> Right (s', f a')
|
214 |
| -#else /* ALEX_MONAD_BYTESTRING */ |
215 |
| - fmap f m = do x <- m; return (f x) |
216 |
| -#endif /* ALEX_MONAD_BYTESTRING */ |
217 | 212 |
|
218 | 213 | instance Applicative Alex where
|
219 |
| -#ifndef ALEX_MONAD_BYTESTRING |
220 | 214 | pure a = Alex $ \s -> Right (s, a)
|
221 | 215 | fa <*> a = Alex $ \s -> case unAlex fa s of
|
222 | 216 | Left msg -> Left msg
|
223 | 217 | Right (s', f) -> case unAlex a s' of
|
224 | 218 | Left msg -> Left msg
|
225 | 219 | Right (s'', b) -> Right (s'', f b)
|
226 |
| -#else /* ALEX_MONAD_BYTESTRING */ |
227 |
| - pure a = Alex $ \s -> Right (s,a) |
228 |
| - (<*>) = Control.Monad.ap |
229 |
| -#endif /* ALEX_MONAD_BYTESTRING */ |
230 | 220 |
|
231 | 221 | instance Monad Alex where
|
232 | 222 | m >>= k = Alex $ \s -> case unAlex m s of
|
|
0 commit comments