public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in dev-haskell/alex/files: alex-3.1.4-ghc-7.10.patch
@ 2015-06-01 20:45 Sergei Trofimovich (slyfox)
  0 siblings, 0 replies; only message in thread
From: Sergei Trofimovich (slyfox) @ 2015-06-01 20:45 UTC (permalink / raw
  To: gentoo-commits

slyfox      15/06/01 20:45:45

  Added:                alex-3.1.4-ghc-7.10.patch
  Log:
  Port to upcoming ghc-7.10.
  
  (Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key 611FF3AA)

Revision  Changes    Path
1.1                  dev-haskell/alex/files/alex-3.1.4-ghc-7.10.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/alex/files/alex-3.1.4-ghc-7.10.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-haskell/alex/files/alex-3.1.4-ghc-7.10.patch?rev=1.1&content-type=text/plain

Index: alex-3.1.4-ghc-7.10.patch
===================================================================
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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-01 20:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 20:45 [gentoo-commits] gentoo-x86 commit in dev-haskell/alex/files: alex-3.1.4-ghc-7.10.patch Sergei Trofimovich (slyfox)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox