packages feed

named-servant-server (empty) → 0.0.1

raw patch · 3 files changed

+101/−0 lines, 3 filesdep +basedep +nameddep +named-servant

Dependencies added: base, named, named-servant, servant, servant-server

Files

+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2020, Kristof Bastiaensen+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+   list of conditions and the following disclaimer.++2. 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.++3. Neither the name of the copyright holder nor the names of its+   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 HOLDER 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.
+ named-servant-server.cabal view
@@ -0,0 +1,27 @@+cabal-version: 1.12+name: named-servant-server+version: 0.0.1+maintainer: kristof@resonata.be+copyright: Kristof Bastiaensen 2020+synopsis: server support for named-servant+license: BSD3+license-file: LICENSE+build-type: Simple++source-repository head+    type: git+    location: https://github.com/kuribas/named-servant-server++library+   default-language: Haskell2010+   Ghc-options: -Wall+   exposed-modules:+        Servant.Named.Server+   hs-source-dirs:+        src+   build-depends:+        base >= 4.7 && < 5,+        servant,+        servant-server,+        named-servant,+        named
+ src/Servant/Named/Server.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE AllowAmbiguousTypes #-}+-- | This module just exports orphan instances to make named-servant+-- work with servers+module Servant.Named.Server () where+import Servant.API+import Servant.Server+import Servant.Named+import Data.Proxy+import GHC.TypeLits+import Named++instance (KnownSymbol sym, FromHttpApiData a, HasServer api context)+      => HasServer (NamedQueryParams sym a :> api) context where++  type ServerT (NamedQueryParams sym a :> api) m =+    sym :! [a] -> ServerT api m++  hoistServerWithContext _ pc nt s =+    hoistServerWithContext (Proxy :: Proxy api) pc nt . s++  route Proxy context subserver =+    route (Proxy :: Proxy (QueryParams sym a :> api)) context $+    fmap (\f x -> f (Arg x)) subserver++instance (KnownSymbol sym, FromHttpApiData a, HasServer api context)+      => HasServer (NamedQueryParam' mods sym a :> api) context where++  type ServerT (NamedQueryParam' mods sym a :> api) m =+    sym :! [a] -> ServerT api m++  hoistServerWithContext _ pc nt s =+    hoistServerWithContext (Proxy :: Proxy api) pc nt . s++  route Proxy context subserver =+    route (Proxy :: Proxy (QueryParams sym a :> api)) context $+    fmap (\f x -> f (Arg x)) subserver