packages feed

hasql-implicits (empty) → 0.1

raw patch · 5 files changed

+260/−0 lines, 5 filesdep +aesondep +basedep +bytestringsetup-changed

Dependencies added: aeson, base, bytestring, containers, hasql, network-ip, ptr, scientific, text, time, uuid, vector

Files

+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2019, Nikita Volkov++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hasql-implicits.cabal view
@@ -0,0 +1,39 @@+name: hasql-implicits+version: 0.1+synopsis: Toolkit for constructing Hasql statements dynamically+homepage: https://github.com/nikita-volkov/hasql-implicits+bug-reports: https://github.com/nikita-volkov/hasql-implicits/issues+author: Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer: Nikita Volkov <nikita.y.volkov@mail.ru>+copyright: (c) 2019, Nikita Volkov+license: MIT+license-file: LICENSE+build-type: Simple+cabal-version: >=1.10++source-repository head+  type: git+  location: git://github.com/nikita-volkov/hasql-implicits.git++library+  hs-source-dirs: library+  default-extensions: BangPatterns, DeriveDataTypeable, DeriveGeneric, DeriveFunctor, DeriveTraversable, GeneralizedNewtypeDeriving, FlexibleContexts, FlexibleInstances, LambdaCase, NoImplicitPrelude, OverloadedStrings, RankNTypes, ScopedTypeVariables, StandaloneDeriving, TypeApplications, TypeFamilies+  ghc-options: -funbox-strict-fields+  default-language: Haskell2010+  exposed-modules:+    Hasql.Implicits.Encoders+  other-modules:+    Hasql.Implicits.Prelude+  build-depends:+    aeson >=1 && <2,+    base >=4.12 && <5,+    bytestring >=0.10 && <0.11,+    containers >=0.6 && <0.7,+    hasql >=1.4 && <1.5,+    network-ip >=0.2 && <1,+    ptr >=0.16.6 && <0.17,+    scientific >=0.2 && <0.4,+    text >=1 && <2,+    time >=1.4 && <2,+    uuid >=1.3 && <1.4,+    vector >=0.10 && <0.13
+ library/Hasql/Implicits/Encoders.hs view
@@ -0,0 +1,91 @@+{-# LANGUAGE CPP #-}+module Hasql.Implicits.Encoders where++import Hasql.Implicits.Prelude+import Hasql.Encoders+import qualified Data.Aeson as Aeson+++{-| Provides a default implementation of parameter encoder. -}+class DefaultParamEncoder a where+  {-| Default parameter encoder with nullability specified. -}+  defaultParam :: NullableOrNot Value a++#define RIGHT_QUOTED(a) a'+#define INSTANCES(VALUE, ENCODER) \+instance DefaultParamEncoder VALUE where { \+  defaultParam = nonNullable ENCODER; \+}; \+instance DefaultParamEncoder [VALUE] where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder [Maybe VALUE] where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder [[VALUE]] where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder [[Maybe VALUE]] where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Vector VALUE) where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Vector (Maybe VALUE)) where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Vector (Vector VALUE)) where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Vector (Vector (Maybe VALUE))) where { \+  defaultParam = (nonNullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe VALUE) where { \+  defaultParam = nullable ENCODER; \+}; \+instance DefaultParamEncoder (Maybe [VALUE]) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe [Maybe VALUE]) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe [[VALUE]]) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe [[Maybe VALUE]]) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe (Vector VALUE)) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe (Vector (Maybe VALUE))) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe (Vector (Vector VALUE))) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nonNullable) ENCODER; \+}; \+instance DefaultParamEncoder (Maybe (Vector (Vector (Maybe VALUE)))) where { \+  defaultParam = (nullable . array . dimension RIGHT_QUOTED(foldl) . dimension RIGHT_QUOTED(foldl) . element . nullable) ENCODER; \+}++INSTANCES(Char, char)+INSTANCES(Double, float8)+INSTANCES(Float, float4)+INSTANCES(Int16, int2)+INSTANCES(Int32, int4)+INSTANCES(Int64, int8)+INSTANCES(ByteString, bytea)+INSTANCES(Scientific, numeric)+INSTANCES(Text, text)+INSTANCES(UTCTime, timestamptz)+INSTANCES(Aeson.Value, jsonb)+INSTANCES(UUID, uuid)+INSTANCES(Day, date)+INSTANCES(DiffTime, interval)+INSTANCES(TimeOfDay, time)+INSTANCES(LocalTime, timestamp)+INSTANCES((TimeOfDay, TimeZone), timetz)+INSTANCES((NetAddr IP), inet)++#undef INSTANCES+#undef RIGHT_QUOTED
+ library/Hasql/Implicits/Prelude.hs view
@@ -0,0 +1,106 @@+module Hasql.Implicits.Prelude+(+  module Exports,+)+where+++-- base+-------------------------+import Control.Applicative as Exports+import Control.Arrow as Exports+import Control.Category as Exports+import Control.Concurrent as Exports+import Control.Exception as Exports+import Control.Monad as Exports hiding (fail, mapM_, sequence_, forM_, msum, mapM, sequence, forM)+import Control.Monad.IO.Class as Exports+import Control.Monad.Fail as Exports+import Control.Monad.Fix as Exports hiding (fix)+import Control.Monad.ST as Exports+import Data.Bits as Exports+import Data.Bool as Exports+import Data.Char as Exports+import Data.Coerce as Exports+import Data.Complex as Exports+import Data.Data as Exports+import Data.Dynamic as Exports+import Data.Either as Exports+import Data.Fixed as Exports+import Data.Foldable as Exports hiding (toList)+import Data.Function as Exports hiding (id, (.))+import Data.Functor as Exports+import Data.Functor.Contravariant as Exports+import Data.Functor.Identity as Exports+import Data.Int as Exports+import Data.IORef as Exports+import Data.Ix as Exports+import Data.List as Exports hiding (sortOn, isSubsequenceOf, uncons, concat, foldr, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, find, maximumBy, minimumBy, mapAccumL, mapAccumR, foldl')+import Data.Maybe as Exports+import Data.Monoid as Exports hiding (Last(..), First(..), (<>))+import Data.Ord as Exports+import Data.Proxy as Exports+import Data.Ratio as Exports+import Data.Semigroup as Exports+import Data.STRef as Exports+import Data.String as Exports+import Data.Traversable as Exports+import Data.Tuple as Exports+import Data.Unique as Exports+import Data.Version as Exports+import Data.Word as Exports+import Debug.Trace as Exports+import Foreign.ForeignPtr as Exports+import Foreign.Ptr as Exports+import Foreign.StablePtr as Exports+import Foreign.Storable as Exports hiding (sizeOf, alignment)+import GHC.Conc as Exports hiding (withMVar, threadWaitWriteSTM, threadWaitWrite, threadWaitReadSTM, threadWaitRead)+import GHC.Exts as Exports (lazy, inline, sortWith, groupWith, IsList(..))+import GHC.Generics as Exports (Generic, Generic1)+import GHC.IO.Exception as Exports+import Numeric as Exports+import Prelude as Exports hiding (fail, concat, foldr, mapM_, sequence_, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, mapM, sequence, id, (.))+import System.Environment as Exports+import System.Exit as Exports+import System.IO as Exports+import System.IO.Error as Exports+import System.IO.Unsafe as Exports+import System.Mem as Exports+import System.Mem.StableName as Exports+import System.Timeout as Exports+import Text.ParserCombinators.ReadP as Exports (ReadP, ReadS, readP_to_S, readS_to_P)+import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readPrec_to_P, readP_to_Prec, readPrec_to_S, readS_to_Prec)+import Text.Printf as Exports (printf, hPrintf)+import Text.Read as Exports (Read(..), readMaybe, readEither)+import Unsafe.Coerce as Exports++-- containers+-------------------------+import Data.Sequence as Exports (Seq)++-- bytestring+-------------------------+import Data.ByteString as Exports (ByteString)++-- text+-------------------------+import Data.Text as Exports (Text)++-- vector+-------------------------+import Data.Vector as Exports (Vector)++-- scientific+-------------------------+import Data.Scientific as Exports (Scientific)++-- uuid+-------------------------+import Data.UUID as Exports (UUID)++-- time+-------------------------+import Data.Time as Exports++-- network-ip+-------------------------+import Network.IP.Addr as Exports (NetAddr, IP)