Ondřej Súkup
b240037859
- add alex-3.1.4-ghc-7.10.patch * temporary disable tests OBS-URL: https://build.opensuse.org/request/show/322621 OBS-URL: https://build.opensuse.org/package/show/devel:languages:haskell/alex?expand=0&rev=43
25 lines
981 B
Diff
25 lines
981 B
Diff
diff --git a/templates/wrappers.hs b/templates/wrappers.hs
|
|
index a1a1a6d..c020cc7 100644
|
|
--- a/templates/wrappers.hs
|
|
+++ b/templates/wrappers.hs
|
|
@@ -284,6 +284,19 @@ runAlex input (Alex f)
|
|
|
|
newtype Alex a = Alex { unAlex :: AlexState -> Either String (AlexState, a) }
|
|
|
|
+instance Functor Alex where
|
|
+ fmap f a = Alex $ \s -> case unAlex a s of
|
|
+ Left msg -> Left msg
|
|
+ Right (s', a') -> Right (s', f a')
|
|
+
|
|
+instance Applicative Alex where
|
|
+ pure a = Alex $ \s -> Right (s, a)
|
|
+ fa <*> a = Alex $ \s -> case unAlex fa s of
|
|
+ Left msg -> Left msg
|
|
+ Right (s', f) -> case unAlex a s' of
|
|
+ Left msg -> Left msg
|
|
+ Right (s'', b) -> Right (s'', f b)
|
|
+
|
|
instance Monad Alex where
|
|
m >>= k = Alex $ \s -> case unAlex m s of
|
|
Left msg -> Left msg
|