packages feed

postgresql-common (empty) → 0.1.0.0

raw patch · 7 files changed

+132/−0 lines, 7 filesdep +attoparsecdep +basedep +bytestringsetup-changed

Dependencies added: attoparsec, base, bytestring, postgresql-common, postgresql-simple

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for postgresql-common++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Ian Duncan (c) 2018++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 Ian Duncan 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.
+ README.md view
@@ -0,0 +1,1 @@+# postgresql-common
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ postgresql-common.cabal view
@@ -0,0 +1,56 @@+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 4c369b6db498a176311e660d7eb0528d548c5f9e7f244fd667b4b4af76d6e669++name:           postgresql-common+version:        0.1.0.0+synopsis:       Library for sharing common PostgreSQL types across Haskell PostgreSQL libraries.+description:    Please see the README on GitHub at <https://github.com/iand675/postgresql-common#readme>+homepage:       https://github.com/iand675/postgresql-common#readme+bug-reports:    https://github.com/iand675/postgresql-common/issues+author:         Ian Duncan+maintainer:     ian@iankduncan.com+copyright:      Ian Duncan+license:        BSD3+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10+extra-source-files:+    ChangeLog.md+    README.md++source-repository head+  type: git+  location: https://github.com/iand675/postgresql-common++library+  exposed-modules:+      Database.PostgreSQL.Types.LSN+  other-modules:+      Paths_postgresql_common+  hs-source-dirs:+      src+  build-depends:+      attoparsec+    , base >=4.7 && <5+    , bytestring+    , postgresql-simple+  default-language: Haskell2010++test-suite postgresql-common-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_postgresql_common+  hs-source-dirs:+      test+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      attoparsec+    , base >=4.7 && <5+    , bytestring+    , postgresql-common+    , postgresql-simple+  default-language: Haskell2010
+ src/Database/PostgreSQL/Types/LSN.hs view
@@ -0,0 +1,38 @@+module Database.PostgreSQL.Types.LSN+    ( LSN(..)+    -- * Utilities+    , encodeLSN+    , decodeLSN+    , lsnParser+    ) where++import Data.ByteString.Char8 (ByteString)+import qualified Data.ByteString.Lazy as BL+import qualified Data.ByteString.Lazy.Builder as Builder+import Data.ByteString.Lazy.Builder.ASCII (word32Hex, word32HexFixed)+import Data.Monoid ((<>))+import Data.Word+import Data.Attoparsec.ByteString.Char8++-- TODO Ord instance+data LSN = LSN !Word32 {- ^ Filepart -} !Word32 {- ^ Offset -}+  deriving (Show, Eq)++instance Ord LSN where+  compare (LSN l0 r0) (LSN l1 r1)+    | l0 > l1 || (l0 == l1 && r0 > r1) = GT+    | l0 < l1 || (l0 == l1 && r0 < r1) = LT+    | otherwise = EQ++lsnParser :: Parser LSN+lsnParser = LSN <$> (hexadecimal <* char '/') <*> hexadecimal++decodeLSN :: ByteString -> Either String LSN+decodeLSN = parseOnly lsnParser++encodeLSN :: LSN -> ByteString+encodeLSN (LSN filepart off) = BL.toStrict $ Builder.toLazyByteString (word32Hex filepart <> Builder.char7 '/' <> word32Hex off)++-- instance ToField LSN where++-- instance FromField LSN where
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"