packages feed

servant-db (empty) → 0.2.0.0

raw patch · 8 files changed

+190/−0 lines, 8 filesdep +basedep +servantsetup-changed

Dependencies added: base, servant

Files

+ CHANGELOG.md view
@@ -0,0 +1,14 @@+0.2.1.0+=======++* Add `Default` type.++0.2.0.0+=======++* Split `Arg` to `ArgNamed` and `ArgPos`. ++0.1.0.0+=======++* Initial release
+ LICENSE view
@@ -0,0 +1,12 @@+Copyright (c) 2016, Anton Gushcha+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.
+ README.md view
@@ -0,0 +1,34 @@+servant-db+==========++The idea of package is to provide [servant](http://haskell-servant.readthedocs.io/en/stable/)-like +DSL for specifying an API for functions stored in RDBMS. ++``` haskell+data RegisterUser = RegisterUser {+  userName :: Text+, userPassword :: Text+, userPhone :: Phone+, userEmail :: Email+}++type API = +       ArgNamed "user" RegisterUser+    :> ArgNamed "isAdmin" Bool+    :> Procedure "registerUser" (Maybe (Only UserId))+  :<|> ArgPos UserId+    :> Procedure "getUser" (Maybe User)+  :<|> Procedure "listUsers" [User]+```++The library adds three custom combinators:+* `ArgNamed name a` - named argument of stored function of type `a`.++* `ArgPos a` - unamed argument of stored function of type `a`.++* `Procedure name a` - named stored function with return type `a`. ++Related libraries:++* [servant-db-postgresql](https://github.com/NCrashed/servant-db-postgresql) - +    derives client for PostgreSQL with [postgresql-query](postgresql-query) library.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ servant-db.cabal view
@@ -0,0 +1,29 @@+name:                 servant-db+version:              0.2.0.0+synopsis:             Servant types for defining API with relational DBs+-- description:+license:              BSD3+license-file:         LICENSE+homepage:             +author:               Anton Gushcha+maintainer:           ncrashed@gmail.com+copyright:            2016 (c) Anton Gushcha+build-type:           Simple+extra-source-files:+  CHANGELOG.md+  README.md+cabal-version:        >=1.10++library+  exposed-modules:+    Servant.API.DB+    Servant.API.DB.Argument+    Servant.API.DB.Procedure+  -- other-modules:+  -- other-extensions:+  build-depends:+      base >= 4.7 && < 5+    , servant >= 0.2 && < 0.10++  hs-source-dirs:       src+  default-language:     Haskell2010
+ src/Servant/API/DB.hs view
@@ -0,0 +1,45 @@+{-|+Module      : Servant.API.DB+Description : Type level DSL for describing API to DB+Portability : Portable++The idea of package is to provide <http://haskell-servant.readthedocs.io/en/stable/ servant>-like+DSL for specifying an API for functions stored in RDBMS.++@+data RegisterUser = RegisterUser {+  userName :: Text+, userPassword :: Text+, userPhone :: Phone+, userEmail :: Email+}++type API =+       ArgNamed "user" RegisterUser+    :> ArgNamed "isAdmin" Bool+    :> Procedure "registerUser" (Maybe (Only UserId))+  :<|> ArgPos UserId+    :> Procedure "getUser" (Maybe User)+  :<|> Procedure "listUsers" [User]+@++The library adds three custom combinators:+* `ArgNamed name a` - named argument of stored function of type `a`.++* `ArgPos a` - unamed argument of stored function of type `a`.++* `Procedure name a` - named stored function with return type `a`.++Related libraries:++* <https://github.com/NCrashed/servant-db-postgresql servant-db-postgresql> -+    derives client for PostgreSQL with <http://hackage.haskell.org/package/postgresql-query postgresql-query> library.++-}+module Servant.API.DB(+    module Reexport+  ) where++import           Servant.API              as Reexport ((:<|>) (..), (:>))+import           Servant.API.DB.Argument  as Reexport+import           Servant.API.DB.Procedure as Reexport
+ src/Servant/API/DB/Argument.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE DataKinds      #-}+{-# LANGUAGE DeriveGeneric  #-}+{-# LANGUAGE KindSignatures #-}+{-|+Module      : Servant.API.DB.Argument+Description : Argument for DB stored functions+Portability : Portable+-}+module Servant.API.DB.Argument(+    ArgPos+  , ArgNamed+  ) where++import           Data.Typeable+import           GHC.Generics+import           GHC.TypeLits++-- | Positional argument of DB stored function with attached type info.+--+-- >>> type SquareProcedure = ArgPos Int :> Procedure "square" Int+data ArgPos a+  deriving (Generic, Typeable)++-- | Named argument of DB stored function with attached name and type info.+--+-- >>> type SquareProcedure = ArgNamed "a" Int :> Procedure "square" Int+data ArgNamed (name :: Symbol) a+  deriving (Generic, Typeable)
+ src/Servant/API/DB/Procedure.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE DataKinds      #-}+{-# LANGUAGE DeriveGeneric  #-}+{-# LANGUAGE KindSignatures #-}+{-|+Module      : Servant.API.DB.Procedure+Description : Endpoint for DB stored function+Portability : Portable+-}+module Servant.API.DB.Procedure(+    Procedure+  ) where++import           Data.Typeable+import           GHC.Generics+import           GHC.TypeLits++-- | Endpoint for SQL procedure.+--+-- Example, stored function that returns current time in seconds:+-- >>> type SelectTime = Procedure "time" Integer+--+-- Example, stored function that squares given 'Int':+-- >>> type SquareProcedure = Arg "a" Int :> Procedure "square" Int+data Procedure (name :: Symbol) a+  deriving (Generic, Typeable)+