From b914a25de326dd937e3a1d05f4eefb46af6da7b4 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Mon, 9 Sep 2024 19:43:39 +0200 Subject: 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 --- src/compiler/GF/Compile/GeneratePMCFG.hs | 4 ++-- src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/compiler/GF/Compile') diff --git a/src/compiler/GF/Compile/GeneratePMCFG.hs b/src/compiler/GF/Compile/GeneratePMCFG.hs index 8383f0624..74615dc98 100644 --- a/src/compiler/GF/Compile/GeneratePMCFG.hs +++ b/src/compiler/GF/Compile/GeneratePMCFG.hs @@ -201,11 +201,11 @@ instance Fail.MonadFail CnvMonad where fail = bug instance Applicative CnvMonad where - pure = return + pure a = CM (\gr c s -> c a s) (<*>) = ap instance Monad CnvMonad where - return a = CM (\gr c s -> c a s) + return = pure CM m >>= k = CM (\gr c s -> m gr (\a s -> unCM (k a) gr c s) s) instance MonadState ([ProtoFCat],[Symbol]) CnvMonad where diff --git a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs index ed3a20ce0..0e76c3205 100644 --- a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs +++ b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs @@ -644,7 +644,7 @@ data TcResult a newtype TcM a = TcM {unTcM :: MetaStore -> [Message] -> TcResult a} instance Monad TcM where - return x = TcM (\ms msgs -> TcOk x ms msgs) + return = pure f >>= g = TcM (\ms msgs -> case unTcM f ms msgs of TcOk x ms msgs -> unTcM (g x) ms msgs TcFail msgs -> TcFail msgs) @@ -659,7 +659,7 @@ instance Fail.MonadFail TcM where instance Applicative TcM where - pure = return + pure x = TcM (\ms msgs -> TcOk x ms msgs) (<*>) = ap instance Functor TcM where -- cgit v1.2.3