packages feed

wai-predicates 0.3.2 → 0.4

raw patch · 6 files changed

+35/−18 lines, 6 filesdep +singletons

Dependencies added: singletons

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@+0.4+-----------------------------------------------------------------------------+- Use `singletons` library instead of `GHC.TypeLits` from base.+- Remove `mapResult` (use `fmap` instead).++0.3.2+-----------------------------------------------------------------------------+- Update dependencies constraints.+ 0.3.1 ----------------------------------------------------------------------------- - Add `fromVault` predicate and `HasVault` type-class.
src/Data/Predicate.hs view
@@ -5,8 +5,8 @@ {-# LANGUAGE TypeOperators #-}  module Data.Predicate-    ( Predicate-    , module Data.Predicate.Result+    ( -- * Predicate+      Predicate     , constant     , failure     , true@@ -19,10 +19,12 @@     , (|||)     , opt     , def-    , mapResult     , mapOkay     , mapFail     , exec+    -- * Result+    , module Data.Predicate.Result+    -- * Product     , module Data.Predicate.Product     ) where @@ -58,7 +60,7 @@  -- | A predicate corresponding to the logical AND connective -- of two predicate.-and, (.&.) :: Predicate a f t -> Predicate a f t' -> Predicate a f (t ::: t')+and :: Predicate a f t -> Predicate a f t' -> Predicate a f (t ::: t') and f g x = f x `cmp` g x   where     cmp (Okay d y) (Okay w z) = Okay (d + w) (y ::: z)@@ -72,7 +74,7 @@ -- If both arguments evaluate to @Okay@ the one with the -- smaller \"delta\" will be preferred, or--if equal--the -- left-hand argument.-or, (.|.) :: Predicate a f t -> Predicate a f t -> Predicate a f t+or :: Predicate a f t -> Predicate a f t -> Predicate a f t or f g x = f x `cmp` g x   where     cmp a@(Okay d _) b@(Okay w _)  = if w < d then b else a@@ -87,7 +89,7 @@ -- If both arguments evaluate to @Okay@ the one with the -- smaller \"delta\" will be preferred, or--if equal--the -- left-hand argument.-orElse, (|||) :: Predicate a f t -> Predicate a f t' -> Predicate a f (Either t t')+orElse :: Predicate a f t -> Predicate a f t' -> Predicate a f (Either t t') orElse f g x = f x `cmp` g x   where     cmp (Okay d y) (Okay w z) = if w < d then Okay w (Right z) else Okay d (Left y)@@ -95,22 +97,26 @@     cmp (Fail   _) (Okay d y) = Okay d (Right y)     cmp (Fail   _) (Fail   y) = Fail y +-- | Alias of 'and'.+(.&.) :: Predicate a f t -> Predicate a f t' -> Predicate a f (t ::: t') (.&.) = and++-- | Alias of 'or'.+(.|.) :: Predicate a f t -> Predicate a f t -> Predicate a f t (.|.) = or-(|||) = orElse --- | Map the result of the given predicate to some other result.-mapResult :: (Result f t -> Result f' t') -> Predicate a f t -> Predicate a f' t'-mapResult f p = f . p+-- | Alias of 'orElse'.+(|||) :: Predicate a f t -> Predicate a f t' -> Predicate a f (Either t t')+(|||) = orElse --- | Like 'mapResult', but only maps the @Okay@ metadata to another result.+-- | Like 'fmap', but only maps the @Okay@ metadata to another result. mapOkay :: (t -> Result f t') -> Predicate a f t -> Predicate a f t' mapOkay f p a =     case p a of         Okay _ x -> f x         Fail   x -> Fail x --- | Like 'mapResult', but only maps the @Fail@ metadata to another result.+-- | Like 'mapOkay', but for the @Fail@ case. mapFail :: (f -> Result f' t) -> Predicate a f t -> Predicate a f' t mapFail f p a =     case p a of@@ -121,12 +127,12 @@ -- i.e. the @Okay@ metadata type becomes a 'Maybe' and in the failure-case -- 'Nothing' is returned. opt :: Predicate a f t -> Predicate a f (Maybe t)-opt = mapResult (result (const $ return Nothing) (\d x -> Okay d (Just x)))+opt = fmap (result (const $ return Nothing) (\d x -> Okay d (Just x)))  -- | A predicate modifier which returns as @Okay@ metadata the provided default -- value if the given predicate fails. def :: t -> Predicate a f t -> Predicate a f t-def t = mapResult (result (const $ return t) Okay)+def t = fmap (result (const $ return t) Okay)  exec :: Predicate a f t -> a -> (f -> b) -> (t -> b) -> b exec p a g f = case p a of
src/Network/Wai/Predicate/Accept.hs view
@@ -16,7 +16,7 @@ import Data.Monoid hiding (All) import Data.Maybe import Data.Predicate-import GHC.TypeLits+import Data.Singletons.TypeLits (Symbol) import Network.HTTP.Types import Network.Wai.Predicate.Error import Network.Wai.Predicate.Request
src/Network/Wai/Predicate/Content.hs view
@@ -15,7 +15,7 @@ import Data.ByteString (ByteString) import Data.Monoid hiding (All) import Data.Predicate-import GHC.TypeLits+import Data.Singletons.TypeLits (Symbol) import Data.Maybe import Network.HTTP.Types.Status import Network.Wai.Predicate.Error
src/Network/Wai/Predicate/MediaType.hs view
@@ -9,7 +9,8 @@  import Data.ByteString (ByteString) import Data.ByteString.Char8 (pack)-import GHC.TypeLits+import Data.Singletons+import Data.Singletons.TypeLits  data Media (t :: Symbol) (s :: Symbol) = Media     { rawType      :: !ByteString
wai-predicates.cabal view
@@ -1,5 +1,5 @@ name:                wai-predicates-version:             0.3.2+version:             0.4 synopsis:            WAI request predicates license:             OtherLicense license-file:        LICENSE@@ -58,6 +58,7 @@       , cookie           == 0.4.*       , case-insensitive >= 1.1    && < 1.3       , http-types       == 0.8.*+      , singletons       == 0.10.*       , transformers     == 0.3.*       , vault            == 0.3.*       , vector           == 0.10.*