packages feed

arrow-list 0.6.1 → 0.6.1.4

raw patch · 8 files changed

+127/−98 lines, 8 filesnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Arrow.ArrowF: arrMF :: (ArrowF f ar, ArrowKleisli m ar) => (a -> m (f c)) -> a ar c
+ Control.Arrow.ArrowF: arrMF :: (ArrowF f arr, ArrowKleisli m arr) => (a -> m (f c)) -> a arr c
- Control.Arrow.ArrowF: class Arrow ar => ArrowF f ar | ar -> f
+ Control.Arrow.ArrowF: class Arrow arr => ArrowF f arr | arr -> f
- Control.Arrow.ArrowF: concatA :: ArrowPlus ar => [a ar b] -> a ar b
+ Control.Arrow.ArrowF: concatA :: ArrowPlus arr => [a arr b] -> a arr b
- Control.Arrow.ArrowF: const :: Arrow ar => b -> a ar b
+ Control.Arrow.ArrowF: const :: Arrow arr => b -> a arr b
- Control.Arrow.ArrowF: constF :: ArrowF f ar => f c -> a ar c
+ Control.Arrow.ArrowF: constF :: ArrowF f arr => f c -> a arr c
- Control.Arrow.ArrowF: embed :: ArrowF f ar => f a ar a
+ Control.Arrow.ArrowF: embed :: ArrowF f arr => f a arr a
- Control.Arrow.ArrowF: filterA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar c) -> a ar a
+ Control.Arrow.ArrowF: filterA :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr c) -> a arr a
- 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: guards :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr c) -> (a arr b) -> (a arr b)
- 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: ifA :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr b) -> (a arr t) -> (a arr t) -> a arr t
- Control.Arrow.ArrowF: isA :: (Alternative f, ArrowF f ar) => (a -> Bool) -> a ar a
+ Control.Arrow.ArrowF: isA :: (Alternative f, ArrowF f arr) => (a -> Bool) -> a arr a
- Control.Arrow.ArrowF: mapF :: ArrowF f ar => (f b -> f c) -> a ar b -> a ar c
+ Control.Arrow.ArrowF: mapF :: ArrowF f arr => (f b -> f c) -> a arr b -> a arr c
- Control.Arrow.ArrowF: maybeA :: (Alternative f, ArrowF f ar) => Maybe a ar a
+ Control.Arrow.ArrowF: maybeA :: (Alternative f, ArrowF f arr) => Maybe a arr a
- Control.Arrow.ArrowF: none :: (Alternative f, ArrowF f ar) => a ar b
+ Control.Arrow.ArrowF: none :: (Alternative f, ArrowF f arr) => a arr b
- Control.Arrow.ArrowF: notA :: (Alternative f, Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar c) -> a ar a
+ Control.Arrow.ArrowF: notA :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr c) -> a arr a
- Control.Arrow.ArrowF: observe :: ArrowF f ar => (a ar b) -> a ar f b
+ Control.Arrow.ArrowF: observe :: ArrowF f arr => (a arr b) -> a arr f b
- Control.Arrow.ArrowF: optional :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar b) -> a ar Maybe b
+ Control.Arrow.ArrowF: optional :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr b) -> a arr Maybe b
- Control.Arrow.ArrowF: orElse :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar b) -> (a ar b) -> a ar b
+ Control.Arrow.ArrowF: orElse :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr b) -> (a arr b) -> a arr b
- Control.Arrow.ArrowF: plus :: (Alternative f, ArrowF f ar) => (a ar b) -> (a ar b) -> a ar b
+ Control.Arrow.ArrowF: plus :: (Alternative f, ArrowF f arr) => (a arr b) -> (a arr b) -> a arr b
- Control.Arrow.ArrowF: results :: (Foldable f, ArrowF f ar) => (a ar b) -> (a ar Bool)
+ Control.Arrow.ArrowF: results :: (Foldable f, ArrowF f arr) => (a arr b) -> (a arr Bool)
- Control.Arrow.ArrowF: unite :: ArrowPlus ar => (b, b) ar b
+ Control.Arrow.ArrowF: unite :: ArrowPlus arr => (b, b) arr b
- Control.Arrow.ArrowF: when :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a ar a) -> (a ar c) -> a ar a
+ Control.Arrow.ArrowF: when :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a arr a) -> (a arr c) -> a arr a
- Control.Arrow.ArrowKleisli: arrIO :: (MonadIO m, ArrowKleisli m ar) => (a -> IO b) -> a ar b
+ Control.Arrow.ArrowKleisli: arrIO :: (MonadIO m, ArrowKleisli m arr) => (a -> IO b) -> a arr b
- Control.Arrow.ArrowKleisli: arrM :: ArrowKleisli m ar => (a -> m b) -> a ar b
+ Control.Arrow.ArrowKleisli: arrM :: ArrowKleisli m arr => (a -> m b) -> a arr b
- Control.Arrow.ArrowKleisli: class (Monad m, Arrow ar) => ArrowKleisli m ar | ar -> m
+ Control.Arrow.ArrowKleisli: class (Monad m, Arrow arr) => ArrowKleisli m arr | arr -> m
- Control.Arrow.ArrowKleisli: constM :: ArrowKleisli m ar => m b -> a ar b
+ Control.Arrow.ArrowKleisli: constM :: ArrowKleisli m arr => m b -> a arr b
- Control.Arrow.ArrowKleisli: effect :: ArrowKleisli m ar => m () -> a ar a
+ Control.Arrow.ArrowKleisli: effect :: ArrowKleisli m arr => m () -> a arr a
- Control.Arrow.ArrowList: arrL :: ArrowList ar => (a -> [b]) -> a ar b
+ Control.Arrow.ArrowList: arrL :: ArrowList arr => (a -> [b]) -> a arr b
- Control.Arrow.ArrowList: class Arrow ar => ArrowList ar
+ Control.Arrow.ArrowList: class Arrow arr => ArrowList arr
- Control.Arrow.ArrowList: concatA :: ArrowPlus ar => [a ar b] -> a ar b
+ Control.Arrow.ArrowList: concatA :: ArrowPlus arr => [a arr b] -> a arr b
- Control.Arrow.ArrowList: empty :: ArrowList ar => (a ar b) -> a ar Bool
+ Control.Arrow.ArrowList: empty :: ArrowList arr => (a arr b) -> a arr Bool
- Control.Arrow.ArrowList: filterA :: (ArrowChoice ar, ArrowList ar) => (a ar c) -> a ar a
+ Control.Arrow.ArrowList: filterA :: (ArrowChoice arr, ArrowList arr) => (a arr c) -> a arr a
- Control.Arrow.ArrowList: guards :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> (a ar b) -> a ar b
+ Control.Arrow.ArrowList: guards :: (ArrowList arr, ArrowChoice arr) => (a arr c) -> (a arr b) -> a arr b
- Control.Arrow.ArrowList: ifA :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> (a ar b) -> (a ar b) -> a ar b
+ Control.Arrow.ArrowList: ifA :: (ArrowList arr, ArrowChoice arr) => (a arr c) -> (a arr b) -> (a arr b) -> a arr b
- Control.Arrow.ArrowList: isA :: ArrowList ar => (a -> Bool) -> a ar a
+ Control.Arrow.ArrowList: isA :: ArrowList arr => (a -> Bool) -> a arr a
- Control.Arrow.ArrowList: list :: ArrowList ar => (a ar b) -> a ar [b]
+ Control.Arrow.ArrowList: list :: ArrowList arr => (a arr b) -> a arr [b]
- Control.Arrow.ArrowList: mapL :: ArrowList ar => ([b] -> [c]) -> (a ar b) -> (a ar c)
+ Control.Arrow.ArrowList: mapL :: ArrowList arr => ([b] -> [c]) -> (a arr b) -> (a arr c)
- Control.Arrow.ArrowList: maybeL :: ArrowList ar => Maybe a ar a
+ Control.Arrow.ArrowList: maybeL :: ArrowList arr => Maybe a arr a
- Control.Arrow.ArrowList: none :: ArrowList ar => a ar b
+ Control.Arrow.ArrowList: none :: ArrowList arr => a arr b
- Control.Arrow.ArrowList: notA :: (ArrowList ar, ArrowChoice ar) => (a ar c) -> a ar a
+ Control.Arrow.ArrowList: notA :: (ArrowList arr, ArrowChoice arr) => (a arr c) -> a arr a
- Control.Arrow.ArrowList: optional :: (ArrowChoice ar, ArrowList ar) => (a ar b) -> a ar Maybe b
+ Control.Arrow.ArrowList: optional :: (ArrowChoice arr, ArrowList arr) => (a arr b) -> a arr Maybe b
- Control.Arrow.ArrowList: orElse :: (ArrowList ar, ArrowChoice ar) => (a ar b) -> (a ar b) -> a ar b
+ Control.Arrow.ArrowList: orElse :: (ArrowList arr, ArrowChoice arr) => (a arr b) -> (a arr b) -> a arr b
- Control.Arrow.ArrowList: unite :: ArrowList ar => (a ar (b, b)) -> a ar b
+ Control.Arrow.ArrowList: unite :: ArrowList arr => (a arr (b, b)) -> a arr b
- Control.Arrow.ArrowList: unlist :: ArrowList ar => [b] ar b
+ Control.Arrow.ArrowList: unlist :: ArrowList arr => [b] arr b
- Control.Arrow.ArrowList: when :: (ArrowList ar, ArrowChoice ar) => (a ar a) -> (a ar b) -> a ar a
+ Control.Arrow.ArrowList: when :: (ArrowList arr, ArrowChoice arr) => (a arr a) -> (a arr b) -> a arr a
- Control.Arrow.List: arrML :: (ArrowList ar, ArrowKleisli m ar) => (a -> m [b]) -> a ar b
+ Control.Arrow.List: arrML :: (ArrowList arr, ArrowKleisli m arr) => (a -> m [b]) -> a arr b

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog++#### 0.6.1.4++* arrow-list is now maintained by Silk and located at https://www.github.com/silkapp/arrow-list
+ README.md view
@@ -0,0 +1,28 @@+# List arrows for Haskell.+[![Build Status](https://travis-ci.org/silkapp/arrow-list.svg?branch=master)](https://travis-ci.org/silkapp/arrow-list)++This small Haskell library provides some type classes, types and functions to+work with list arrows and the more generalized container arrows. List arrows+represent computations that may return multiple outputs. Making functions that+return lists an instance of both the `Category` and `Arrow` type classes allow+you to easily compose multiple computations into one with standard building+blocks.++This package provides:++  - A type class `ArrowList` for embedding functions that produce a list of+    outputs into _some_ list arrow.++  - A list of utility functions for working with list-arrows, these functions+    are based on the `ArrowList` type class so they are not tied one specific+    instance.++  - A concrete list arrow type that is implemented as a `Kleisli` arrow over+    the `ListT` list monad transformer. In short, you can both build pure list+    arrows and list arrows that produce tributary effects.++  - Not list arrow specific: A type class `ArrowKleisli` for embedding monadic+    computations into an arrow.++  - A type class `ArrowF` for embedding functions that produce a some+    Foldable + Alternative functor of outputs into _some_ container arrow.
arrow-list.cabal view
@@ -1,40 +1,41 @@-Name:             arrow-list-Version:          0.6.1-Synopsis:         List arrows for Haskell.-Description:+name:                arrow-list+version:             0.6.1.4+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.--Category:         Control-License:          BSD3-License-file:     LICENSE-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+author:              Sebastiaan Visser+maintainer:          code@silk.co+category:            Control+license:             BSD3+homepage:            https://github.com/silkapp/arrow-list+bug-reports:         https://github.com/silkapp/arrow-list/issues+license-file:        LICENSE+build-type:          Simple+cabal-version:       >= 1.6 -  Build-Depends:    base       == 4.*-                  , mtl        >= 1.1 && < 2.2-                  , containers >= 0.3 && < 0.6+extra-source-files:+  README.md+  CHANGELOG.md -  Exposed-modules:  Control.Arrow.ArrowF-                    Control.Arrow.ArrowKleisli-                    Control.Arrow.ArrowList-                    Control.Arrow.List-                    Control.Arrow.Sequence-                    Control.Monad.Sequence+source-repository head+  type:     git+  location: git://github.com/silkapp/arrow-list.git +library+  ghc-options:       -Wall+  hs-source-dirs:    src+  exposed-modules:+    Control.Arrow.ArrowF+    Control.Arrow.ArrowKleisli+    Control.Arrow.ArrowList+    Control.Arrow.List+    Control.Arrow.Sequence+    Control.Monad.Sequence+  build-depends:+      base ==4.*+    , containers >= 0.3 && < 0.6+    , mtl >= 1.1 && < 2.2
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 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.+class Arrow arr => ArrowF f arr | arr -> f where+  embed   :: f a `arr` a                 -- ^ Use a container as the input for an arrow.+  observe :: (a `arr` b) -> a `arr` f b  -- ^ Get the result as container.  -- | Embed a monadic function returning an ordered list into a container arrow. -arrMF :: (ArrowF f ar, ArrowKleisli m ar) => (a -> m (f c)) -> a `ar` c+arrMF :: (ArrowF f arr, ArrowKleisli m arr) => (a -> m (f c)) -> a `arr` c arrMF x = embed . arrM x  -- | Map a function over the result collection of a container arrow. -mapF :: ArrowF f ar => (f b -> f c) -> a `ar` b -> a `ar` c+mapF :: ArrowF f arr => (f b -> f c) -> a `arr` b -> a `arr` 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 ar => (b, b) `ar` b+unite :: ArrowPlus arr => (b, b) `arr` b unite = arr fst <+> arr snd  -- | Skip the input and produce a constant output. -const :: Arrow ar => b -> a `ar` b+const :: Arrow arr => b -> a `arr` b const = arr . Prelude.const  -- | Collect the results of applying multiple arrows to the same input. -concatA :: ArrowPlus ar => [a `ar` b] -> a `ar` b+concatA :: ArrowPlus arr => [a `arr` b] -> a `arr` b concatA = foldr (<+>) zeroArrow  -- | Join the results of two arrows, like (<+>) from ArrowPlus. -plus :: (Alternative f, ArrowF f ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b+plus :: (Alternative f, ArrowF f arr) => (a `arr` b) -> (a `arr` b) -> a `arr` 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 ar => f c -> a `ar` c+constF :: ArrowF f arr => f c -> a `arr` c constF f = embed . const f  -- | Ignore the input and produce no results. Like `zeroArrow'. -none :: (Alternative f, ArrowF f ar) => a `ar` b+none :: (Alternative f, ArrowF f arr) => a `arr` b none = constF empty  -- | Returns a `Bool' indicating whether the input arrow produces a container -- with any results. -results :: (Foldable f, ArrowF f ar) => (a `ar` b) -> (a `ar` Bool)+results :: (Foldable f, ArrowF f arr) => (a `arr` b) -> (a `arr` 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 ar) => (a -> Bool) -> a `ar` a+isA :: (Alternative f, ArrowF f arr) => (a -> Bool) -> a `arr` 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 ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` t) -> (a `ar` t) -> a `ar` t+ifA :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` b) -> (a `arr` t) -> (a `arr` t) -> a `arr` 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 ar, ArrowChoice ar) => (a `ar` a) -> (a `ar` c) -> a `ar` a+when :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` a) -> (a `arr` c) -> a `arr` 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 ar, ArrowChoice ar) => (a `ar` c) -> (a `ar` b) -> (a `ar` b)+guards :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` c) -> (a `arr` b) -> (a `arr` 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 ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a+filterA :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` c) -> a `arr` 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 ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a+notA :: (Alternative f, Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` c) -> a `arr` a notA c = ifA c none id  -- | Apply the input arrow, when the arrow does not produces any results the@@ -154,20 +154,19 @@  infix 6 `orElse` -orElse :: (Foldable f, ArrowF f ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b-orElse a = ifA a a +orElse :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` b) -> (a `arr` b) -> a `arr` 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 ar) => Maybe a `ar` a+maybeA :: (Alternative f, ArrowF f arr) => Maybe a `arr` 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 ar, ArrowChoice ar) => (a `ar` b) -> a `ar` Maybe b+optional :: (Foldable f, ArrowF f arr, ArrowChoice arr) => (a `arr` b) -> a `arr` Maybe b optional a = ifA a (arr Just . a) (arr (const Nothing))-
src/Control/Arrow/ArrowKleisli.hs view
@@ -15,18 +15,17 @@ import Control.Monad.Trans import Prelude hiding ((.), id) -class (Monad m, Arrow ar) => ArrowKleisli m ar | ar -> m where-  arrM :: (a -> m b) -> a `ar` b+class (Monad m, Arrow arr) => ArrowKleisli m arr | arr -> m where+  arrM :: (a -> m b) -> a `arr` b  instance Monad m => ArrowKleisli m (Kleisli m) where   arrM f = Kleisli f -constM :: ArrowKleisli m ar => m b -> a `ar` b+constM :: ArrowKleisli m arr => m b -> a `arr` b constM a = arrM (const a) -effect :: ArrowKleisli m ar => m () -> a `ar` a+effect :: ArrowKleisli m arr => m () -> a `arr` a effect a = arrM (\b -> a >> return b) -arrIO :: (MonadIO m, ArrowKleisli m ar) => (a -> IO b) -> a `ar` b+arrIO :: (MonadIO m, ArrowKleisli m arr) => (a -> IO b) -> a `arr` b arrIO f = arrM (liftIO . f)-
src/Control/Arrow/ArrowList.hs view
@@ -40,63 +40,63 @@ import Prelude hiding ((.), id)  -- | The `ArrowList' class represents two possible actions:--- +-- --   1. Lifting functions from one value to a list of values into a list arrow.--- +-- --   2. Mapping a function over the result list of a list arrow. -class Arrow ar => ArrowList ar where-  arrL :: (a -> [b]) -> a `ar` b-  mapL :: ([b] -> [c]) -> (a `ar` b) -> (a `ar` c)+class Arrow arr => ArrowList arr where+  arrL :: (a -> [b]) -> a `arr` b+  mapL :: ([b] -> [c]) -> (a `arr` b) -> (a `arr` c)  -- | Create a list arrow of an input list. -unlist :: ArrowList ar => [b] `ar` b+unlist :: ArrowList arr => [b] `arr` 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 ar => (a `ar` (b, b)) -> a `ar` b+unite :: ArrowList arr => (a `arr` (b, b)) -> a `arr` b unite = mapL (concatMap (\(a, b) -> [a, b]))  -- | Ignore the input and produce no results. Like `zeroArrow'. -none :: ArrowList ar => a `ar` b+none :: ArrowList arr => a `arr` b none = arrL (const [])  -- | Collect the results of applying multiple arrows to the same input. -concatA :: ArrowPlus ar => [a `ar` b] -> a `ar` b+concatA :: ArrowPlus arr => [a `arr` b] -> a `arr` b concatA = foldr (<+>) zeroArrow  -- | Collect the entire results of an list arrow as a singleton value in the -- result list. -list :: ArrowList ar => (a `ar` b) -> a `ar` [b]+list :: ArrowList arr => (a `arr` b) -> a `arr` [b] list = mapL return  -- | Returns a `Bool' indicating whether the input arrow produce any results. -empty :: ArrowList ar => (a `ar` b) -> a `ar` Bool+empty :: ArrowList arr => (a `arr` b) -> a `arr` 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 ar => (a -> Bool) -> a `ar` a+isA :: ArrowList arr => (a -> Bool) -> a `arr` 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 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 :: (ArrowList arr, ArrowChoice arr)+    => (a `arr` c)  -- ^ Arrow used as condition.+    -> (a `arr` b)  -- ^ Arrow to use when condition has results.+    -> (a `arr` b)  -- ^ Arrow to use when condition has no results.+    -> a `arr` 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 ar, ArrowChoice ar)-     => (a `ar` a)  -- ^ The arrow to apply,-     -> (a `ar` b)  -- ^ when this conditional holds.-     -> a `ar` a+when :: (ArrowList arr, ArrowChoice arr)+     => (a `arr` a)  -- ^ The arrow to apply,+     -> (a `arr` b)  -- ^ when this conditional holds.+     -> a `arr` 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 ar, ArrowChoice ar)-       => (a `ar` c)  -- ^ When this condition holds,-       -> (a `ar` b)  -- ^ then apply this arrow.-       -> a `ar` b+guards :: (ArrowList arr, ArrowChoice arr)+       => (a `arr` c)  -- ^ When this condition holds,+       -> (a `arr` b)  -- ^ then apply this arrow.+       -> a `arr` 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 ar, ArrowList ar) => (a `ar` c) -> a `ar` a+filterA :: (ArrowChoice arr, ArrowList arr) => (a `arr` c) -> a `arr` a filterA c = ifA c id none  -- | Negation list arrow. Only accept the input when the condition produces no -- output. -notA :: (ArrowList ar, ArrowChoice ar) => (a `ar` c) -> a `ar` a+notA :: (ArrowList arr, ArrowChoice arr) => (a `arr` c) -> a `arr` a notA c = ifA c none id  -- | Apply the input arrow, when the arrow does not produces any results the@@ -143,19 +143,18 @@  infix 8 `orElse` -orElse :: (ArrowList ar, ArrowChoice ar) => (a `ar` b) -> (a `ar` b) -> a `ar` b-orElse a = ifA a a +orElse :: (ArrowList arr, ArrowChoice arr) => (a `arr` b) -> (a `arr` b) -> a `arr` 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 ar => Maybe a `ar` a+maybeL :: ArrowList arr => Maybe a `arr` 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 ar, ArrowList ar) => (a `ar` b) -> a `ar` Maybe b+optional :: (ArrowChoice arr, ArrowList arr) => (a `arr` b) -> a `arr` Maybe b optional a = ifA a (arr Just . a) (arr (const Nothing))-
src/Control/Arrow/List.hs view
@@ -52,6 +52,5 @@  -- * Embed a monadic function returning lists. -arrML :: (ArrowList ar, ArrowKleisli m ar) => (a -> m [b]) -> a `ar` b+arrML :: (ArrowList arr, ArrowKleisli m arr) => (a -> m [b]) -> a `arr` b arrML x = unlist . arrM x-
src/Control/Monad/Sequence.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# OPTIONS -fno-warn-orphans #-}+{-# LANGUAGE CPP #-} module Control.Monad.Sequence ( -- * The `Sequence' monad transformer.@@ -16,8 +17,7 @@ import Data.Traversable import Prelude hiding (mapM) -#if MIN_VERSION_containers(0,5,2)-#else+#if !MIN_VERSION_containers(0,5,2) instance Applicative Seq where   pure  = return   (<*>) = ap@@ -65,4 +65,3 @@  instance MonadIO m => MonadIO (SeqT m) where   liftIO = lift . liftIO-