arrow-list 0.6 → 0.6.1
raw patch · 6 files changed
+78/−68 lines, 6 filesdep ~basedep ~containersdep ~mtlPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, containers, mtl
API changes (from Hackage documentation)
- Control.Arrow.ArrowF: arrMF :: (ArrowF f ~>, ArrowKleisli m ~>) => (a -> m (f c)) -> a ~> c
+ Control.Arrow.ArrowF: arrMF :: (ArrowF f ar, ArrowKleisli m ar) => (a -> m (f c)) -> a ar c
- Control.Arrow.ArrowF: class Arrow ~> => ArrowF f ~> | ~> -> f
+ Control.Arrow.ArrowF: class Arrow ar => ArrowF f ar | ar -> f
- Control.Arrow.ArrowF: concatA :: ArrowPlus ~> => [a ~> b] -> a ~> b
+ Control.Arrow.ArrowF: concatA :: ArrowPlus ar => [a ar b] -> a ar b
- Control.Arrow.ArrowF: const :: Arrow ~> => b -> a ~> b
+ Control.Arrow.ArrowF: const :: Arrow ar => b -> a ar b
- Control.Arrow.ArrowF: constF :: ArrowF f ~> => f c -> a ~> c
+ Control.Arrow.ArrowF: constF :: ArrowF f ar => f c -> a ar c
- Control.Arrow.ArrowF: embed :: ArrowF f ~> => f a ~> a
+ Control.Arrow.ArrowF: embed :: ArrowF f ar => f a ar a
- Control.Arrow.ArrowF: filterA :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> a ~> a
+ Control.Arrow.ArrowF: filterA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar c) -> a ar a
- Control.Arrow.ArrowF: guards :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> (a ~> b) -> (a ~> b)
+ Control.Arrow.ArrowF: guards :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar c) -> (a ar b) -> (a ar b)
- Control.Arrow.ArrowF: ifA :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> (a ~> t) -> (a ~> t) -> a ~> t
+ Control.Arrow.ArrowF: ifA :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar b) -> (a ar t) -> (a ar t) -> a ar t
- Control.Arrow.ArrowF: isA :: (Alternative f, ArrowF f ~>) => (a -> Bool) -> a ~> a
+ Control.Arrow.ArrowF: isA :: (Alternative f, ArrowF f ar) => (a -> Bool) -> a ar a
- Control.Arrow.ArrowF: mapF :: ArrowF f ~> => (f b -> f c) -> a ~> b -> a ~> c
+ Control.Arrow.ArrowF: mapF :: ArrowF f ar => (f b -> f c) -> a ar b -> a ar c
- Control.Arrow.ArrowF: maybeA :: (Alternative f, ArrowF f ~>) => Maybe a ~> a
+ Control.Arrow.ArrowF: maybeA :: (Alternative f, ArrowF f ar) => Maybe a ar a
- Control.Arrow.ArrowF: none :: (Alternative f, ArrowF f ~>) => a ~> b
+ Control.Arrow.ArrowF: none :: (Alternative f, ArrowF f ar) => a ar b
- Control.Arrow.ArrowF: notA :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> a ~> a
+ Control.Arrow.ArrowF: notA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar c) -> a ar a
- Control.Arrow.ArrowF: observe :: ArrowF f ~> => (a ~> b) -> a ~> f b
+ Control.Arrow.ArrowF: observe :: ArrowF f ar => (a ar b) -> a ar f b
- Control.Arrow.ArrowF: optional :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> a ~> Maybe b
+ Control.Arrow.ArrowF: optional :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar b) -> a ar Maybe b
- Control.Arrow.ArrowF: orElse :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> (a ~> b) -> a ~> b
+ Control.Arrow.ArrowF: orElse :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar b) -> (a ar b) -> a ar b
- Control.Arrow.ArrowF: plus :: (Alternative f, ArrowF f ~>) => (a ~> b) -> (a ~> b) -> a ~> b
+ Control.Arrow.ArrowF: plus :: (Alternative f, ArrowF f ar) => (a ar b) -> (a ar b) -> a ar b
- Control.Arrow.ArrowF: results :: (Foldable f, ArrowF f ~>) => (a ~> b) -> (a ~> Bool)
+ Control.Arrow.ArrowF: results :: (Foldable f, ArrowF f ar) => (a ar b) -> (a ar Bool)
- Control.Arrow.ArrowF: unite :: ArrowPlus ~> => (b, b) ~> b
+ Control.Arrow.ArrowF: unite :: ArrowPlus ar => (b, b) ar b
- Control.Arrow.ArrowF: when :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> a) -> (a ~> c) -> a ~> a
+ Control.Arrow.ArrowF: when :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar a) -> (a ar c) -> a ar a
- Control.Arrow.ArrowKleisli: arrIO :: (MonadIO m, ArrowKleisli m ~>) => (a -> IO b) -> a ~> b
+ Control.Arrow.ArrowKleisli: arrIO :: (MonadIO m, ArrowKleisli m ar) => (a -> IO b) -> a ar b
- Control.Arrow.ArrowKleisli: arrM :: ArrowKleisli m ~> => (a -> m b) -> a ~> b
+ Control.Arrow.ArrowKleisli: arrM :: ArrowKleisli m ar => (a -> m b) -> a ar b
- Control.Arrow.ArrowKleisli: class (Monad m, Arrow ~>) => ArrowKleisli m ~> | ~> -> m
+ Control.Arrow.ArrowKleisli: class (Monad m, Arrow ar) => ArrowKleisli m ar | ar -> m
- Control.Arrow.ArrowKleisli: constM :: ArrowKleisli m ~> => m b -> a ~> b
+ Control.Arrow.ArrowKleisli: constM :: ArrowKleisli m ar => m b -> a ar b
- Control.Arrow.ArrowKleisli: effect :: ArrowKleisli m ~> => m () -> a ~> a
+ Control.Arrow.ArrowKleisli: effect :: ArrowKleisli m ar => m () -> a ar a
- Control.Arrow.ArrowList: arrL :: ArrowList ~> => (a -> [b]) -> a ~> b
+ Control.Arrow.ArrowList: arrL :: ArrowList ar => (a -> [b]) -> a ar b
- Control.Arrow.ArrowList: class Arrow ~> => ArrowList ~>
+ Control.Arrow.ArrowList: class Arrow ar => ArrowList ar
- Control.Arrow.ArrowList: concatA :: ArrowPlus ~> => [a ~> b] -> a ~> b
+ Control.Arrow.ArrowList: concatA :: ArrowPlus ar => [a ar b] -> a ar b
- Control.Arrow.ArrowList: empty :: ArrowList ~> => (a ~> b) -> a ~> Bool
+ Control.Arrow.ArrowList: empty :: ArrowList ar => (a ar b) -> a ar Bool
- Control.Arrow.ArrowList: filterA :: (ArrowChoice ~>, ArrowList ~>) => (a ~> c) -> a ~> a
+ Control.Arrow.ArrowList: filterA :: (ArrowChoice ar, ArrowList ar) => (a ar c) -> a ar a
- Control.Arrow.ArrowList: guards :: (ArrowList ~>, ArrowChoice ~>) => (a ~> c) -> (a ~> b) -> a ~> b
+ Control.Arrow.ArrowList: guards :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> (a ar b) -> a ar b
- Control.Arrow.ArrowList: ifA :: (ArrowList ~>, ArrowChoice ~>) => (a ~> c) -> (a ~> b) -> (a ~> b) -> a ~> b
+ Control.Arrow.ArrowList: ifA :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> (a ar b) -> (a ar b) -> a ar b
- Control.Arrow.ArrowList: isA :: ArrowList ~> => (a -> Bool) -> a ~> a
+ Control.Arrow.ArrowList: isA :: ArrowList ar => (a -> Bool) -> a ar a
- Control.Arrow.ArrowList: list :: ArrowList ~> => (a ~> b) -> a ~> [b]
+ Control.Arrow.ArrowList: list :: ArrowList ar => (a ar b) -> a ar [b]
- Control.Arrow.ArrowList: mapL :: ArrowList ~> => ([b] -> [c]) -> (a ~> b) -> (a ~> c)
+ Control.Arrow.ArrowList: mapL :: ArrowList ar => ([b] -> [c]) -> (a ar b) -> (a ar c)
- Control.Arrow.ArrowList: maybeL :: ArrowList ~> => Maybe a ~> a
+ Control.Arrow.ArrowList: maybeL :: ArrowList ar => Maybe a ar a
- Control.Arrow.ArrowList: none :: ArrowList ~> => a ~> b
+ Control.Arrow.ArrowList: none :: ArrowList ar => a ar b
- Control.Arrow.ArrowList: notA :: (ArrowList ~>, ArrowChoice ~>) => (a ~> c) -> a ~> a
+ Control.Arrow.ArrowList: notA :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> a ar a
- Control.Arrow.ArrowList: optional :: (ArrowChoice ~>, ArrowList ~>) => (a ~> b) -> a ~> Maybe b
+ Control.Arrow.ArrowList: optional :: (ArrowChoice ar, ArrowList ar) => (a ar b) -> a ar Maybe b
- Control.Arrow.ArrowList: orElse :: (ArrowList ~>, ArrowChoice ~>) => (a ~> b) -> (a ~> b) -> a ~> b
+ Control.Arrow.ArrowList: orElse :: (ArrowList ar, ArrowChoice ar) => (a ar b) -> (a ar b) -> a ar b
- Control.Arrow.ArrowList: unite :: ArrowList ~> => (a ~> (b, b)) -> a ~> b
+ Control.Arrow.ArrowList: unite :: ArrowList ar => (a ar (b, b)) -> a ar b
- Control.Arrow.ArrowList: unlist :: ArrowList ~> => [b] ~> b
+ Control.Arrow.ArrowList: unlist :: ArrowList ar => [b] ar b
- Control.Arrow.ArrowList: when :: (ArrowList ~>, ArrowChoice ~>) => (a ~> a) -> (a ~> b) -> a ~> a
+ Control.Arrow.ArrowList: when :: (ArrowList ar, ArrowChoice ar) => (a ar a) -> (a ar b) -> a ar a
- Control.Arrow.List: arrML :: (ArrowList ~>, ArrowKleisli m ~>) => (a -> m [b]) -> a ~> b
+ Control.Arrow.List: arrML :: (ArrowList ar, ArrowKleisli m ar) => (a -> m [b]) -> a ar b
Files
- arrow-list.cabal +19/−13
- src/Control/Arrow/ArrowF.hs +21/−21
- src/Control/Arrow/ArrowKleisli.hs +5/−5
- src/Control/Arrow/ArrowList.hs +28/−28
- src/Control/Arrow/List.hs +1/−1
- src/Control/Monad/Sequence.hs +4/−0
arrow-list.cabal view
@@ -1,29 +1,35 @@ Name: arrow-list-Version: 0.6+Version: 0.6.1 Synopsis: List arrows for Haskell.-Description: This small Haskell library provides some type class, types- and functions to work with list (and list-like) arrows. List- arrows represent computations that may return multiple- outputs. Making functions that return lists an instance of- both the `Category` and `Arrow` type class allow you to- easily compose multiple computations into one with standard- building blocks.+Description:+ This small Haskell library provides some type class, types and functions to+ work with list (and list-like) arrows. List arrows represent computations+ that may return multiple outputs. Making functions that return lists an+ instance of both the `Category` and `Arrow` type class allow you to easily+ compose multiple computations into one with standard building blocks. Category: Control License: BSD3 License-file: LICENSE-Author: Sebastiaan Visser-Maintainer: haskell@fvisser.nl Build-Type: Simple Cabal-Version: >= 1.6 +Author: Sebastiaan Visser+Maintainer: Sebastiaan Visser <code@fvisser.nl>+Homepage: https://github.com/sebastiaanvisser/arrow-list+Bug-Reports: http://github.com/sebastiaanvisser/arrow-list/issues++Source-Repository head+ Type: git+ Location: git://github.com/sebastiaanvisser/arrow-list.git+ Library GHC-Options: -Wall HS-Source-Dirs: src - Build-Depends: base ==4.*- , mtl >= 1.1 && < 2.1- , containers >=0.3 && < 0.5+ Build-Depends: base == 4.*+ , mtl >= 1.1 && < 2.2+ , containers >= 0.3 && < 0.6 Exposed-modules: Control.Arrow.ArrowF Control.Arrow.ArrowKleisli
src/Control/Arrow/ArrowF.hs view
@@ -50,62 +50,62 @@ -- assume the container type has an 'Applicative', an 'Alternative' and a -- 'Foldable' instance. -class Arrow (~>) => ArrowF f (~>) | (~>) -> f where- embed :: f a ~> a -- ^ Use a container as the input for an arrow.- observe :: (a ~> b) -> a ~> f b -- ^ Get the result as container.+class Arrow ar => ArrowF f ar | ar -> f where+ embed :: f a `ar` a -- ^ Use a container as the input for an arrow.+ observe :: (a `ar` b) -> a `ar` f b -- ^ Get the result as container. -- | Embed a monadic function returning an ordered list into a container arrow. -arrMF :: (ArrowF f (~>), ArrowKleisli m (~>)) => (a -> m (f c)) -> a ~> c+arrMF :: (ArrowF f ar, ArrowKleisli m ar) => (a -> m (f c)) -> a `ar` c arrMF x = embed . arrM x -- | Map a function over the result collection of a container arrow. -mapF :: ArrowF f (~>) => (f b -> f c) -> a ~> b -> a ~> c+mapF :: ArrowF f ar => (f b -> f c) -> a `ar` b -> a `ar` c mapF f a = embed . arr f . observe a -- | Take the output of an arrow producing two results and concatenate them -- into the result of the container arrow. -unite :: ArrowPlus (~>) => (b, b) ~> b+unite :: ArrowPlus ar => (b, b) `ar` b unite = arr fst <+> arr snd -- | Skip the input and produce a constant output. -const :: Arrow (~>) => b -> a ~> b+const :: Arrow ar => b -> a `ar` b const = arr . Prelude.const -- | Collect the results of applying multiple arrows to the same input. -concatA :: ArrowPlus (~>) => [a ~> b] -> a ~> b+concatA :: ArrowPlus ar => [a `ar` b] -> a `ar` b concatA = foldr (<+>) zeroArrow -- | Join the results of two arrows, like (<+>) from ArrowPlus. -plus :: (Alternative f, ArrowF f (~>)) => (a ~> b) -> (a ~> b) -> a ~> b+plus :: (Alternative f, ArrowF f ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b plus a b = embed . arr (\(x, y) -> x <|> y) . (observe a &&& observe b) -- | Skip the input and produce a constant output specified as a container. -constF :: ArrowF f (~>) => f c -> a ~> c+constF :: ArrowF f ar => f c -> a `ar` c constF f = embed . const f -- | Ignore the input and produce no results. Like `zeroArrow'. -none :: (Alternative f, ArrowF f (~>)) => a ~> b+none :: (Alternative f, ArrowF f ar) => a `ar` b none = constF empty -- | Returns a `Bool' indicating whether the input arrow produces a container -- with any results. -results :: (Foldable f, ArrowF f (~>)) => (a ~> b) -> (a ~> Bool)+results :: (Foldable f, ArrowF f ar) => (a `ar` b) -> (a `ar` Bool) results a = arr (not . null . toList) . observe a -- | Create a filtering container arrow by mapping a predicate function over the -- input. When the predicate returns `True' the input will be returned in the -- output container, when `False' the empty container is returned. -isA :: (Alternative f, ArrowF f (~>)) => (a -> Bool) -> a ~> a+isA :: (Alternative f, ArrowF f ar) => (a -> Bool) -> a `ar` a isA f = embed . arr (\a -> if f a then pure a else empty) -- | Use the result of a container arrow as a conditional, like an if-then-else@@ -113,7 +113,7 @@ -- used, when the first arrow produces no results the /else/ arrow will be -- used. -ifA :: (Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> b) -> (a ~> t) -> (a ~> t) -> a ~> t+ifA :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` t) -> (a `ar` t) -> a `ar` t ifA c t e = proc i -> do x <- results c -< i; if x then t -< i else e -< i -- | Apply a container arrow only when a conditional arrow produces any@@ -123,7 +123,7 @@ infix 7 `when` -when :: (Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> a) -> (a ~> c) -> a ~> a+when :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` a) -> (a `ar` c) -> a `ar` a when a c = ifA c a id -- | Apply a container arrow only when a conditional arrow produces any@@ -133,19 +133,19 @@ infix 8 `guards` -guards :: (Alternative f, Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> c) -> (a ~> b) -> (a ~> b)+guards :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` c) -> (a `ar` b) -> (a `ar` b) guards c a = ifA c a none -- | Filter the results of an arrow with a predicate arrow, when the filter -- condition produces results the input is accepted otherwise it is excluded. -filterA :: (Alternative f, Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> c) -> a ~> a+filterA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a filterA c = ifA c id none -- | Negation container arrow. Only accept the input when the condition -- produces no output. -notA :: (Alternative f, Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> c) -> a ~> a+notA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a notA c = ifA c none id -- | Apply the input arrow, when the arrow does not produces any results the@@ -154,20 +154,20 @@ infix 6 `orElse` -orElse :: (Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> b) -> (a ~> b) -> a ~> b+orElse :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b orElse a = ifA a a -- | Map a `Maybe' input to a container output. When the Maybe is a `Nothing' -- an empty container will be returned, `Just' will result in a singleton -- container. -maybeA :: (Alternative f, ArrowF f (~>)) => Maybe a ~> a+maybeA :: (Alternative f, ArrowF f ar) => Maybe a `ar` a maybeA = embed . arr (maybe empty pure) -- | Apply a container arrow, when there are no results a `Nothing' will be -- returned, otherwise the results will be wrapped in a `Just'. This function -- always produces result. -optional :: (Foldable f, ArrowF f (~>), ArrowChoice (~>)) => (a ~> b) -> a ~> Maybe b+optional :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` b) -> a `ar` Maybe b optional a = ifA a (arr Just . a) (arr (const Nothing))
src/Control/Arrow/ArrowKleisli.hs view
@@ -15,18 +15,18 @@ import Control.Monad.Trans import Prelude hiding ((.), id) -class (Monad m, Arrow (~>)) => ArrowKleisli m (~>) | (~>) -> m where- arrM :: (a -> m b) -> a ~> b+class (Monad m, Arrow ar) => ArrowKleisli m ar | ar -> m where+ arrM :: (a -> m b) -> a `ar` b instance Monad m => ArrowKleisli m (Kleisli m) where arrM f = Kleisli f -constM :: ArrowKleisli m (~>) => m b -> a ~> b+constM :: ArrowKleisli m ar => m b -> a `ar` b constM a = arrM (const a) -effect :: ArrowKleisli m (~>) => m () -> a ~> a+effect :: ArrowKleisli m ar => m () -> a `ar` a effect a = arrM (\b -> a >> return b) -arrIO :: (MonadIO m, ArrowKleisli m (~>)) => (a -> IO b) -> a ~> b+arrIO :: (MonadIO m, ArrowKleisli m ar) => (a -> IO b) -> a `ar` b arrIO f = arrM (liftIO . f)
src/Control/Arrow/ArrowList.hs view
@@ -45,58 +45,58 @@ -- -- 2. Mapping a function over the result list of a list arrow. -class Arrow (~>) => ArrowList (~>) where- arrL :: (a -> [b]) -> a ~> b- mapL :: ([b] -> [c]) -> (a ~> b) -> (a ~> c)+class Arrow ar => ArrowList ar where+ arrL :: (a -> [b]) -> a `ar` b+ mapL :: ([b] -> [c]) -> (a `ar` b) -> (a `ar` c) -- | Create a list arrow of an input list. -unlist :: ArrowList (~>) => [b] ~> b+unlist :: ArrowList ar => [b] `ar` b unlist = arrL id -- | Take the output of an arrow producing two results and concatenate them -- into the result of the list arrow. -unite :: ArrowList (~>) => (a ~> (b, b)) -> a ~> b+unite :: ArrowList ar => (a `ar` (b, b)) -> a `ar` b unite = mapL (concatMap (\(a, b) -> [a, b])) -- | Ignore the input and produce no results. Like `zeroArrow'. -none :: ArrowList (~>) => a ~> b+none :: ArrowList ar => a `ar` b none = arrL (const []) -- | Collect the results of applying multiple arrows to the same input. -concatA :: ArrowPlus (~>) => [a ~> b] -> a ~> b+concatA :: ArrowPlus ar => [a `ar` b] -> a `ar` b concatA = foldr (<+>) zeroArrow -- | Collect the entire results of an list arrow as a singleton value in the -- result list. -list :: ArrowList (~>) => (a ~> b) -> a ~> [b]+list :: ArrowList ar => (a `ar` b) -> a `ar` [b] list = mapL return -- | Returns a `Bool' indicating whether the input arrow produce any results. -empty :: ArrowList (~>) => (a ~> b) -> a ~> Bool+empty :: ArrowList ar => (a `ar` b) -> a `ar` Bool empty = mapL (\xs -> [if null xs then True else False]) -- | Create a filtering list arrow by mapping a predicate function over the -- input. When the predicate returns `True' the input will be returned in the -- output list, when `False' the empty list is returned. -isA :: ArrowList (~>) => (a -> Bool) -> a ~> a+isA :: ArrowList ar => (a -> Bool) -> a `ar` a isA f = arrL (\a -> if f a then [a] else []) -- | Use the result a list arrow as a conditional, like an if-then-else arrow. -- When the first arrow produces any results the /then/ arrow will be used, -- when the first arrow produces no results the /else/ arrow will be used. -ifA :: (ArrowList (~>), ArrowChoice (~>))- => (a ~> c) -- ^ Arrow used as condition.- -> (a ~> b) -- ^ Arrow to use when condition has results.- -> (a ~> b) -- ^ Arrow to use when condition has no results.- -> a ~> b+ifA :: (ArrowList ar, ArrowChoice ar)+ => (a `ar` c) -- ^ Arrow used as condition.+ -> (a `ar` b) -- ^ Arrow to use when condition has results.+ -> (a `ar` b) -- ^ Arrow to use when condition has no results.+ -> a `ar` b ifA c t e = proc i -> do x <- empty c -< i; if x then e -< i else t -< i -- | Apply a list arrow only when a conditional arrow produces any results.@@ -106,10 +106,10 @@ infix 8 `when` -when :: (ArrowList (~>), ArrowChoice (~>))- => (a ~> a) -- ^ The arrow to apply,- -> (a ~> b) -- ^ when this conditional holds.- -> a ~> a+when :: (ArrowList ar, ArrowChoice ar)+ => (a `ar` a) -- ^ The arrow to apply,+ -> (a `ar` b) -- ^ when this conditional holds.+ -> a `ar` a when a c = ifA c a id -- | Apply a list arrow only when a conditional arrow produces any results.@@ -119,22 +119,22 @@ infix 8 `guards` -guards :: (ArrowList (~>), ArrowChoice (~>))- => (a ~> c) -- ^ When this condition holds,- -> (a ~> b) -- ^ then apply this arrow.- -> a ~> b+guards :: (ArrowList ar, ArrowChoice ar)+ => (a `ar` c) -- ^ When this condition holds,+ -> (a `ar` b) -- ^ then apply this arrow.+ -> a `ar` b guards c a = ifA c a none -- | Filter the results of an arrow with a predicate arrow, when the filter -- condition produces results the input is accepted otherwise it is excluded. -filterA :: (ArrowChoice (~>), ArrowList (~>)) => (a ~> c) -> a ~> a+filterA :: (ArrowChoice ar, ArrowList ar) => (a `ar` c) -> a `ar` a filterA c = ifA c id none -- | Negation list arrow. Only accept the input when the condition produces no -- output. -notA :: (ArrowList (~>), ArrowChoice (~>)) => (a ~> c) -> a ~> a+notA :: (ArrowList ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a notA c = ifA c none id -- | Apply the input arrow, when the arrow does not produces any results the@@ -143,19 +143,19 @@ infix 8 `orElse` -orElse :: (ArrowList (~>), ArrowChoice (~>)) => (a ~> b) -> (a ~> b) -> a ~> b+orElse :: (ArrowList ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b orElse a = ifA a a -- | Map a `Maybe' input to a list output. When the Maybe is a `Nothing' an -- empty list will be returned, `Just' will result in a singleton list. -maybeL :: ArrowList (~>) => Maybe a ~> a+maybeL :: ArrowList ar => Maybe a `ar` a maybeL = arrL (maybe [] return) -- | Apply a list arrow, when there are no results a `Nothing' will be -- returned, otherwise the results will be wrapped in a `Just'. This function -- always produces result. -optional :: (ArrowChoice (~>), ArrowList (~>)) => (a ~> b) -> a ~> Maybe b+optional :: (ArrowChoice ar, ArrowList ar) => (a `ar` b) -> a `ar` Maybe b optional a = ifA a (arr Just . a) (arr (const Nothing))
src/Control/Arrow/List.hs view
@@ -52,6 +52,6 @@ -- * Embed a monadic function returning lists. -arrML :: (ArrowList (~>), ArrowKleisli m (~>)) => (a -> m [b]) -> a ~> b+arrML :: (ArrowList ar, ArrowKleisli m ar) => (a -> m [b]) -> a `ar` b arrML x = unlist . arrM x
src/Control/Monad/Sequence.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# OPTIONS -fno-warn-orphans #-} module Control.Monad.Sequence (@@ -15,6 +16,8 @@ import Data.Traversable import Prelude hiding (mapM) +#if MIN_VERSION_containers(0,5,2)+#else instance Applicative Seq where pure = return (<*>) = ap@@ -22,6 +25,7 @@ instance Alternative Seq where empty = mzero (<|>) = mplus+#endif -- | Parameterizable `Sequence' monad, with an inner monad. The semantics of -- `SeqT' are comparable to that of `ListT`.