summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Data/BacktrackM.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2014-08-13 22:16:18 +0000
committerhallgren <hallgren@chalmers.se>2014-08-13 22:16:18 +0000
commitcd5193b7e19e7ff5e49cdeafe149fdeec8e19fb0 (patch)
treec006a3b453b8b290b09379cf5cb2777421558e70 /src/compiler/GF/Data/BacktrackM.hs
parenta06351b6250dd456299565f13eba6ed02dd2a07b (diff)
Fix warnings in 16 modules, mostly forward compatibility warnings from GHC 7.8
Diffstat (limited to 'src/compiler/GF/Data/BacktrackM.hs')
-rw-r--r--src/compiler/GF/Data/BacktrackM.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/GF/Data/BacktrackM.hs b/src/compiler/GF/Data/BacktrackM.hs
index 4e84022f4..f5ae63997 100644
--- a/src/compiler/GF/Data/BacktrackM.hs
+++ b/src/compiler/GF/Data/BacktrackM.hs
@@ -29,6 +29,7 @@ module GF.Data.BacktrackM (
) where
import Data.List
+import Control.Applicative
import Control.Monad
import Control.Monad.State.Class
@@ -60,6 +61,10 @@ foldFinalStates f b (BM m) s = m (\x s b -> f s b) s b
finalStates :: BacktrackM s () -> s -> [s]
finalStates bm = map fst . runBM bm
+instance Applicative (BacktrackM s) where
+ pure = return
+ (<*>) = ap
+
instance Monad (BacktrackM s) where
return a = BM (\c s b -> c a s b)
BM m >>= k = BM (\c s b -> m (\a s b -> unBM (k a) c s b) s b)
@@ -69,6 +74,10 @@ instance Monad (BacktrackM s) where
instance Functor (BacktrackM s) where
fmap f (BM m) = BM (\c s b -> m (\a s b -> c (f a) s b) s b)
+instance Alternative (BacktrackM s) where
+ empty = mzero
+ (<|>) = mplus
+
instance MonadPlus (BacktrackM s) where
mzero = BM (\c s b -> b)
(BM f) `mplus` (BM g) = BM (\c s b -> g c s $! f c s b)