packages feed

wai-lens (empty) → 0.1

raw patch · 4 files changed

+181/−0 lines, 4 filesdep +basedep +bytestringdep +http-typessetup-changed

Dependencies added: base, bytestring, http-types, lens, network, text, vault, wai

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Richard Wallace++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Richard Wallace nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,5 @@+#!/usr/bin/env runhaskell++import Distribution.Simple++main = defaultMain
+ src/Network/Wai/Lens.hs view
@@ -0,0 +1,113 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeSynonymInstances #-}++module Network.Wai.Lens where++import Control.Lens+import Data.ByteString (ByteString)+import Data.Foldable+import Data.Monoid+import Data.Text (Text)+import Data.Tuple+import Data.Vault.Lazy (Vault)+import Network.Socket+import Network.HTTP.Types+import qualified Network.Wai as W++class HasMethod s a | s -> a where+  method :: Lens' s a++instance HasMethod W.Request Method where+  method = lens W.requestMethod $ \rq m -> rq { W.requestMethod = m }+  {-# INLINE method #-}++class HasHttpVersion s a | s -> a where+  httpVersion :: Lens' s a++instance HasHttpVersion W.Request HttpVersion where+  httpVersion = lens W.httpVersion $ \rq v -> rq { W.httpVersion = v }+  {-# INLINE httpVersion #-}++class HasRawPathInfo s a | s -> a where+  rawPathInfo :: Lens' s a++instance HasRawPathInfo W.Request ByteString where+  rawPathInfo = lens W.rawPathInfo $ \rq p -> rq { W.rawPathInfo = p }+  {-# INLINE rawPathInfo #-}++class HasRawQueryString s a | s -> a where+  rawQueryString :: Lens' s a++instance HasRawQueryString W.Request ByteString where+  rawQueryString = lens W.rawQueryString $ \rq q -> rq { W.rawQueryString = q }+  {-# INLINE rawQueryString #-}++class HasHeaders s a | s -> a where+  headers :: Lens' s a++instance HasHeaders W.Request RequestHeaders where+  headers = lens W.requestHeaders $ \rq h -> rq { W.requestHeaders = h }+  {-# INLINE headers #-}++class HasRemoteHost s a | s -> a where+  remoteHost :: Lens' s a++instance HasRemoteHost W.Request SockAddr where+  remoteHost = lens W.remoteHost $ \rq h -> rq { W.remoteHost = h }+  {-# INLINE remoteHost #-}++class HasPathInfo s a | s -> a where+  pathInfo :: Lens' s a++instance HasPathInfo W.Request [Text] where+  pathInfo = lens W.pathInfo $ \rq p -> rq { W.pathInfo = p }+  {-# INLINE pathInfo #-}++class HasQueryString s a | s -> a where+  queryString :: Lens' s a++instance HasQueryString W.Request Query where+  queryString = lens W.queryString $ \rq q -> rq { W.queryString = q }+  {-# INLINE queryString #-}++class HasRequestBody s a | s -> a where+  requestBody :: Lens' s a++instance HasRequestBody W.Request (IO ByteString) where+  requestBody = lens W.requestBody $ \rq b -> rq { W.requestBody = b }+  {-# INLINE requestBody #-}++class HasVault s a | s -> a where+  vault :: Lens' s a++instance HasVault W.Request Vault where+  vault  = lens W.vault $ \rq v -> rq { W.vault = v }+  {-# INLINE vault #-}++class HasRequestBodyLength s a | s -> a where+  requestBodyLength :: Lens' s a++instance HasRequestBodyLength W.Request W.RequestBodyLength where+  requestBodyLength = lens W.requestBodyLength $ \rq l -> rq { W.requestBodyLength = l }+  {-# INLINE requestBodyLength #-}++class HasStatus s a | s -> a where+  status :: Lens' s a++-- | Useful for looking up query string or header values.+--+-- @+-- req ^. headers . value "Content-Type"+-- @+value+  :: (Eq a, Foldable f)+  => a+  -> (b -> Const (First b) b)+  -> f (a, b)+  -> Const (First b) (f (a, b))+value n = folded . to swap . aside (only n) . _1+{-# INLINE value #-}+
+ wai-lens.cabal view
@@ -0,0 +1,33 @@+name:                wai-lens+version:             0.1+synopsis:            Lenses for WAI+description:         Lenses for WAI+homepage:            https://github.com/webcrank/wai-lens+bug-reports:         https://github.com/webcrank/wai-lens/issues+license:             BSD3+license-file:        LICENSE+author:              Richard Wallace+maintainer:          rwallace@thewallacepack.net+copyright:           (c) 2015 Richard Wallace+category:            Network, Web+build-type:          Simple+cabal-version:       >=1.8++source-repository    head+  type:              git+  location:          https://github.com/webcrank/wai-lens.git++library+  hs-source-dirs:    src++  exposed-modules:   Network.Wai.Lens++  build-depends:     base           >=4.6 && <5+                  , bytestring     >=0.9.1.10 && <0.11+                  , http-types     >=0.8 && <0.9+                  , lens           >=4.5 && <5+                  , network        >=2.5 && <2.7+                  , text           >=0.11 && <1.3+                  , vault          >=0.3 && <0.4+                  , wai            >=3.0 && <4+