Skip to content

Commit ddb9245

Browse files
committed
Always use the Functor and Applicative instances from ALEX_MONAD
They behave exactly the same, so there's no need to keep two sets of implementations around.
1 parent 13fd23e commit ddb9245

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

templates/wrappers.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#if defined(ALEX_MONAD) || defined(ALEX_MONAD_BYTESTRING)
88
import Control.Applicative as App (Applicative (..))
9-
import qualified Control.Monad (ap)
109
#endif
1110

1211
import Data.Word (Word8)
@@ -207,26 +206,17 @@ runAlex input__ (Alex f)
207206
newtype Alex a = Alex { unAlex :: AlexState -> Either String (AlexState, a) }
208207

209208
instance Functor Alex where
210-
#ifndef ALEX_MONAD_BYTESTRING
211209
fmap f a = Alex $ \s -> case unAlex a s of
212210
Left msg -> Left msg
213211
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 */
217212

218213
instance Applicative Alex where
219-
#ifndef ALEX_MONAD_BYTESTRING
220214
pure a = Alex $ \s -> Right (s, a)
221215
fa <*> a = Alex $ \s -> case unAlex fa s of
222216
Left msg -> Left msg
223217
Right (s', f) -> case unAlex a s' of
224218
Left msg -> Left msg
225219
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 */
230220

231221
instance Monad Alex where
232222
m >>= k = Alex $ \s -> case unAlex m s of

0 commit comments

Comments
 (0)