Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 574d54b

Browse files
authored
Merge pull request #46 from garyb/monadrec
Add MonadRec instance
2 parents 562a031 + a2acaab commit 574d54b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Test/StrongCheck/Gen.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import Control.Monad.Eff.Console (logShow, CONSOLE)
6464
import Control.Monad.List.Trans as ListT
6565
import Control.Monad.Trampoline (runTrampoline, Trampoline)
6666
import Control.Monad.Gen as CMG
67+
import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM)
6768
import Control.MonadPlus (class MonadPlus)
6869
import Control.MonadZero (class MonadZero)
6970
import Control.Plus (class Plus)
@@ -597,6 +598,11 @@ instance monadZeroGenT :: Monad f => MonadZero (GenT f)
597598

598599
instance monadPlusGenT :: Monad f => MonadPlus (GenT f)
599600

601+
instance monadRecGenT :: MonadRec f => MonadRec (GenT f) where
602+
tailRecM k a = k a >>= case _ of
603+
Loop b -> tailRecM k b
604+
Done r -> pure r
605+
600606
instance lazyGenT :: Monad f => CL.Lazy (GenT f a) where
601607
defer f = GenT $ CL.defer (unGen <<< f)
602608

0 commit comments

Comments
 (0)