packages feed

selective 0.4 → 0.4.1

raw patch · 4 files changed

+41/−6 lines, 4 filesdep ~QuickCheck

Dependency ranges changed: QuickCheck

Files

CHANGES.md view
@@ -1,5 +1,9 @@ # Change log +## 0.4.1++* Allow newer QuickCheck.+ ## 0.4  * Add multi-way selective functors: `Control.Selective.Multi`.
selective.cabal view
@@ -1,5 +1,5 @@ name:          selective-version:       0.4+version:       0.4.1 synopsis:      Selective applicative functors license:       MIT license-file:  LICENSE@@ -74,7 +74,7 @@     build-depends:      base                   >= 4.7     && < 5,                         containers             >= 0.5.5.1 && < 0.7,                         mtl                    >= 2.2.1   && < 2.3,-                        QuickCheck             >= 2.8     && < 2.14,+                        QuickCheck             >= 2.8     && < 2.15,                         selective,                         tasty                  >= 0.11,                         tasty-expected-failure >= 0.11,
src/Control/Selective/Multi.hs view
@@ -45,7 +45,6 @@  import Control.Applicative ((<**>)) import Data.Functor.Identity-import Data.Semigroup ((<>))  ------------------------ Meet two friends: Sigma and Pi ------------------------ -- | A generalised sum type where @t@ stands for the type of constructor "tags".
test/Sketch.hs view
@@ -456,15 +456,15 @@ grdS :: Applicative f => f (a -> Bool) -> f a -> f (Either a a) grdS f a = (selector <$> (f <*> a)) <*> a   where-      selector = bool Right Left +      selector = bool Right Left  -- | McCarthy's conditional, denoted p -> f,g is a well-known functional--- combinator, which suggests that, to reason about conditionals, one may +-- combinator, which suggests that, to reason about conditionals, one may -- seek help in the algebra of coproducts. -- -- This combinator is very similar to the very nature of the 'select' -- operator and benefits from a series of properties and laws.-condS :: Selective f => f (b -> Bool) -> f (b -> c) -> f (b -> c) -> f b -> f c +condS :: Selective f => f (b -> Bool) -> f (b -> c) -> f (b -> c) -> f b -> f c condS p f g = (\r -> branch r f g) . grdS p  ------------------------ Carter Schonwald's copatterns -------------------------@@ -636,3 +636,35 @@         \(x1, x2) -> Left (\(y1, y2) ->             (either ($y1) id (k1 x1)) (either ($y2) id (k2 x2))) +-- class Applicative f => SelectiveQ f where+--     select :: Enumerable t => f (g a) -> (t ~> f :*: u) -> f (Sigma u)++-- instance (Selective f, Selective g) => Selective (f :*: g) where++-- instance Selective (Maybe :*: Maybe) where++-- instance Selective Maybe where+--     match sigma pi = sigma >>= \s -> pureSelect s pi++++-- data Value a b = Likely a | Unlikely b+-- Some kind of "Sigma arrows"+-- Sigma t -> (Match t (Sigma s)) -> Sigma s+-- Sigma t -> (t ~> Sigma s) -> Sigma s++-- branchU :: forall f a b c. SelectiveU f => f (Either a b) -> f (a -> c) -> f (b -> c) -> f c+-- branchU x f g = selectU (toAB <$> x) h+--   where+--     -- toAB :: Either a b -> (AB a b x, x)+--     toAB (Left  a) = (A, a)+--     toAB (Right b) = (B, b)+--     -- h :: AB a b x -> f (x -> c)+--     h A = f+--     h B = g++-- applyS :: forall f a b. SelectiveS f => f a -> f (a -> b) -> f b+-- applyS x f = sigmaSelect (Sigma Refl <$> x) h+--   where+--     h :: forall x. Refl a x -> f (x -> b)+--     h Refl = f