packages feed

logict 0.2.2 → 0.2.3

raw patch · 3 files changed

+63/−8 lines, 3 files

Files

Control/Monad/Logic.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE UndecidableInstances, Rank2Types, FlexibleInstances, MultiParamTypeClasses #-}  ------------------------------------------------------------------------- -- |@@ -159,7 +159,7 @@  instance T.Traversable Logic where     traverse g l = runLogic l (\a ft -> cons <$> g a <*> ft) (pure mzero)-     where cons a l = return a `mplus` l+     where cons a l' = return a `mplus` l'  -- haddock doesn't like generalized newtype deriving, so I'm writing -- instances by hand
Control/Monad/Logic/Class.hs view
@@ -20,8 +20,6 @@  module Control.Monad.Logic.Class (MonadLogic(..), reflect) where -import Control.Monad- import qualified Control.Monad.State.Lazy as LazyST import qualified Control.Monad.State.Strict as StrictST @@ -132,6 +130,18 @@                             Just ((a,s'), m) ->                                 return (Just (a, StrictST.StateT (\_ -> m)), s') +    interleave ma mb = StrictST.StateT $ \s ->+                        StrictST.runStateT ma s `interleave` StrictST.runStateT mb s++    ma >>- f = StrictST.StateT $ \s ->+                StrictST.runStateT ma s >>- \(a,s') -> StrictST.runStateT (f a) s'++    ifte t th el = StrictST.StateT $ \s -> ifte (StrictST.runStateT t s)+                                                (\(a,s') -> StrictST.runStateT (th a) s')+                                                (StrictST.runStateT el s)++    once ma = StrictST.StateT $ \s -> once (StrictST.runStateT ma s)+ instance (MonadLogic m) => MonadLogic (LazyST.StateT s m) where     msplit sm = LazyST.StateT $ \s ->                     do r <- msplit (LazyST.runStateT sm s)@@ -140,6 +150,18 @@                             Just ((a,s'), m) ->                                 return (Just (a, LazyST.StateT (\_ -> m)), s') +    interleave ma mb = LazyST.StateT $ \s ->+                        LazyST.runStateT ma s `interleave` LazyST.runStateT mb s++    ma >>- f = LazyST.StateT $ \s ->+                LazyST.runStateT ma s >>- \(a,s') -> LazyST.runStateT (f a) s'++    ifte t th el = LazyST.StateT $ \s -> ifte (LazyST.runStateT t s)+                                              (\(a,s') -> LazyST.runStateT (th a) s')+                                              (LazyST.runStateT el s)++    once ma = LazyST.StateT $ \s -> once (LazyST.runStateT ma s)+ instance (MonadLogic m, Monoid w) => MonadLogic (StrictWT.WriterT w m) where     msplit wm = StrictWT.WriterT $                     do r <- msplit (StrictWT.runWriterT wm)@@ -148,6 +170,20 @@                             Just ((a,w), m) ->                                 return (Just (a, StrictWT.WriterT m), w) +    interleave ma mb = StrictWT.WriterT $+                        StrictWT.runWriterT ma `interleave` StrictWT.runWriterT mb++    ma >>- f = StrictWT.WriterT $+                StrictWT.runWriterT ma >>- \(a,w) ->+                    StrictWT.runWriterT (StrictWT.tell w >> f a)++    ifte t th el = StrictWT.WriterT $+                    ifte (StrictWT.runWriterT t)+                         (\(a,w) -> StrictWT.runWriterT (StrictWT.tell w >> th a))+                         (StrictWT.runWriterT el)++    once ma = StrictWT.WriterT $ once (StrictWT.runWriterT ma)+ instance (MonadLogic m, Monoid w) => MonadLogic (LazyWT.WriterT w m) where     msplit wm = LazyWT.WriterT $                     do r <- msplit (LazyWT.runWriterT wm)@@ -155,3 +191,17 @@                             Nothing -> return (Nothing, mempty)                             Just ((a,w), m) ->                                 return (Just (a, LazyWT.WriterT m), w)++    interleave ma mb = LazyWT.WriterT $+                        LazyWT.runWriterT ma `interleave` LazyWT.runWriterT mb++    ma >>- f = LazyWT.WriterT $+                LazyWT.runWriterT ma >>- \(a,w) ->+                    LazyWT.runWriterT (LazyWT.tell w >> f a)++    ifte t th el = LazyWT.WriterT $+                    ifte (LazyWT.runWriterT t)+                         (\(a,w) -> LazyWT.runWriterT (LazyWT.tell w >> th a))+                         (LazyWT.runWriterT el)++    once ma = LazyWT.WriterT $ once (LazyWT.runWriterT ma)
logict.cabal view
@@ -1,5 +1,5 @@ Name:                   logict-Version:                0.2.2+Version:                0.2.3 Description:            A continuation-based, backtracking, logic programming monad.                         An adaptation of the two-continuation implementation found                         in the paper "Backtracking, Interleaving, and Terminating@@ -13,12 +13,17 @@ Author:                 Dan Doel Maintainer:             dan.doel@gmail.com Homepage:               http://code.haskell.org/~dolio/logict-Stability:              Experimental, based on paper++Stability:              Experimental Tested-With:            GHC Build-Depends:          base, mtl>=1.0.1+Build-Type:             Simple+ Exposed-Modules:        Control.Monad.Logic,                         Control.Monad.Logic.Class Extensions:             MultiParamTypeClasses,-                        UndecidableInstances-GHC-Options:            -O2+                        UndecidableInstances,+                        Rank2Types,+                        FlexibleInstances+GHC-Options:            -O2 -Wall