Skip to content

Commit 3ee4f6c

Browse files
committed
added MonadFix and fix how return is defined
1 parent b480ead commit 3ee4f6c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/compiler/api/GF/Infra/CheckM.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import GF.Text.Pretty
3131
import System.FilePath(makeRelative)
3232
import Control.Parallel.Strategies(parList,rseq,using)
3333
import Control.Monad(liftM,ap)
34+
import Control.Monad.Fix(MonadFix(..))
3435
import Control.Applicative(Applicative(..))
3536
import qualified Control.Monad.Fail as Fail
3637

@@ -45,7 +46,6 @@ newtype Check a
4546
instance Functor Check where fmap = liftM
4647

4748
instance Monad Check where
48-
return x = Check $ \msgs -> Success x msgs
4949
f >>= g = Check $ \ws ->
5050
case unCheck f ws of
5151
Success x msgs -> unCheck (g x) msgs
@@ -54,8 +54,14 @@ instance Monad Check where
5454
instance Fail.MonadFail Check where
5555
fail = raise
5656

57+
instance MonadFix Check where
58+
mfix f = Check $ \msgs ->
59+
let Check mf = f x
60+
r@(Success x _) = mf msgs
61+
in r
62+
5763
instance Applicative Check where
58-
pure = return
64+
pure x = Check $ \msgs -> Success x msgs
5965
(<*>) = ap
6066

6167
instance ErrorMonad Check where

0 commit comments

Comments
 (0)