summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Data
diff options
context:
space:
mode:
authorInari Listenmaa <inari.listenmaa@gmail.com>2024-09-09 19:43:39 +0200
committerInari Listenmaa <inari.listenmaa@gmail.com>2025-08-02 16:39:31 +0200
commitb914a25de326dd937e3a1d05f4eefb46af6da7b4 (patch)
treee816d5ec4b91425f3f7e41dd8bd75a2681ff524c /src/compiler/GF/Data
parent1037b209ae225d5de604ff832d915c590ced4c38 (diff)
define return in terms of pure, >> as *>, mappend as <>
In preparation for deprecation, see https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid and https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
Diffstat (limited to 'src/compiler/GF/Data')
-rw-r--r--src/compiler/GF/Data/BacktrackM.hs4
-rw-r--r--src/compiler/GF/Data/ErrM.hs4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/GF/Data/BacktrackM.hs b/src/compiler/GF/Data/BacktrackM.hs
index 970de5c06..69bc2c29b 100644
--- a/src/compiler/GF/Data/BacktrackM.hs
+++ b/src/compiler/GF/Data/BacktrackM.hs
@@ -64,11 +64,11 @@ finalStates :: BacktrackM s () -> s -> [s]
finalStates bm = map fst . runBM bm
instance Applicative (BacktrackM s) where
- pure = return
+ pure a = BM (\c s b -> c a s b)
(<*>) = ap
instance Monad (BacktrackM s) where
- return a = BM (\c s b -> c a s b)
+ return = pure
BM m >>= k = BM (\c s b -> m (\a s b -> unBM (k a) c s b) s b)
where unBM (BM m) = m
diff --git a/src/compiler/GF/Data/ErrM.hs b/src/compiler/GF/Data/ErrM.hs
index 288c61919..133a49b73 100644
--- a/src/compiler/GF/Data/ErrM.hs
+++ b/src/compiler/GF/Data/ErrM.hs
@@ -34,7 +34,7 @@ fromErr :: a -> Err a -> a
fromErr a = err (const a) id
instance Monad Err where
- return = Ok
+ return = pure
Ok a >>= f = f a
Bad s >>= f = Bad s
@@ -54,7 +54,7 @@ instance Functor Err where
fmap f (Bad s) = Bad s
instance Applicative Err where
- pure = return
+ pure = Ok
(<*>) = ap
-- | added by KJ