sebfisch / stream-monad

Simple, Fair and Terminating Backtracking Monad
http://github.com/sebfisch/stream-monad
Other
9 stars 12 forks source link

extensions to stream-monad #1

Closed warrenharris closed 14 years ago

warrenharris commented 14 years ago

Hi Sebastian,

I've been reading the paper "Backtracking, interleaving, and terminating monad transformers" and would like to contribute a few operators from the paper to your stream-monad implementation, namely runL, ifte, once and cut (gnot). I hope you can include these in your next release. Thanks,

Warren

sebfisch commented 14 years ago

Thank you for the implementations. I think your additions roughly amount to adding an instance for Control.Monad.Logic where msplit, ifte, and once are like your implementations, interleave is mplus, and (>>-) is (>>=). Only cut is not in this class so needs to be added independently.

I wonder what the advantage of runL is over runStream, because:

runL Nothing  = runStream
runL (Just n) = take n . runStream

I don't see a reason to add runL but adding an instance for MonadLogic seems useful and I will add one to the next release.

warrenharris commented 14 years ago

Hi Sebastian,

Very good points. I'm still somewhat new to these backtracking implementations (and haskell in general), and it hadn't occurred to me to make these be part of MonadLogic. Let me rework it and send you another pull request.

Warren

sebfisch commented 14 years ago

superseded by #4.