You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that runIdentity (observeAllT (mzero `mplus` pure 1)) was producing []. I then noticed this happened anytime mzero was the left argument to mplus.
The MonadPlus instance currently looks like this:
instanceMonadm=>MonadPlus (MLm) where
mzero =ML empty
mplus (toView -> m) n = fromView $ m >>=return.\caseNothing->NothingJust (h,t) ->Just (h, cat t n)
where cat (ML l) (ML r) =ML$ l .>< r
However, that first case means that mzero stops the rest of the computation. I changed the code to this:
instanceMonadm=>MonadPlus (MLm) where
mzero =ML empty
mplus (toView -> m) n = fromView $ m >>=\caseNothing-> toView n
Just (h,t) ->return (Just (h, cat t n))
where cat (ML l) (ML r) =ML$ l .>< r
And that seems to fix the issue. In particular, I have some local test code that compares breadth-first search and iterative deepening depth-first search and they now return equivalent results. And I was also able to confirm it now returns the same results as LogicT from Control.Monad.Logic. So I think the change I made is correct.
The text was updated successfully, but these errors were encountered:
BTW, I uploaded a these ideas to hackage as logict-sequence so that I could use them more easily. I tried to give you and Oleg credit wherever I could. So I hope you don't mind: https://hackage.haskell.org/package/logict-sequence
I noticed that
runIdentity (observeAllT (mzero `mplus` pure 1))
was producing[]
. I then noticed this happened anytimemzero
was the left argument tomplus
.The
MonadPlus
instance currently looks like this:However, that first case means that
mzero
stops the rest of the computation. I changed the code to this:And that seems to fix the issue. In particular, I have some local test code that compares breadth-first search and iterative deepening depth-first search and they now return equivalent results. And I was also able to confirm it now returns the same results as
LogicT
fromControl.Monad.Logic
. So I think the change I made is correct.The text was updated successfully, but these errors were encountered: