monadplus 1.4.2 → 1.4.3
raw patch · 2 files changed
+15/−3 lines, 2 filesdep ~basenew-uploader
Dependency ranges changed: base
Files
- monadplus.cabal +1/−1
- src/Control/Monad/Plus.hs +14/−2
monadplus.cabal view
@@ -1,6 +1,6 @@ name: monadplus-version: 1.4.2+version: 1.4.3 cabal-version: >= 1.10 author: Hans Hoglund maintainer: Hans Hoglund <hans@hanshoglund.se>
src/Control/Monad/Plus.hs view
@@ -61,7 +61,10 @@ ) where import Control.Monad hiding (msum)-import Control.Applicative+import Control.Applicative +import Control.Category (Category)+import qualified Control.Category as Category+import Data.Semigroup as Sem import Data.Monoid import Data.List (partition) import Data.Maybe (listToMaybe, maybeToList, catMaybes, mapMaybe, fromMaybe)@@ -253,8 +256,17 @@ empty = Partial (const Nothing) Partial f <|> Partial g = Partial $ \x -> f x <|> g x +instance Category Partial where+ id = Partial (always id)+ Partial f . Partial g = Partial $ \x -> do+ y <- g x+ f y++instance Sem.Semigroup (Partial a b) where+ (<>) = mplus+ instance Monoid (Partial a b) where mempty = mzero- mappend = mplus+ mappend = (<>)