Skip to content

Build fixes #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion postgres-wire.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ library
, stm
, tls
, cryptonite
, store-core
, store-core >= 0.4.1 && < 0.5
, scientific
, uuid
default-language: Haskell2010
Expand Down
4 changes: 2 additions & 2 deletions src/Database/PostgreSQL/Driver/Settings.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Database.PostgreSQL.Driver.Settings
module Database.PostgreSQL.Driver.Settings
( ConnectionSettings(..)
, TlsMode
, TlsMode (..)
, defaultConnectionSettings
) where

Expand Down
15 changes: 6 additions & 9 deletions src/Database/PostgreSQL/Protocol/Store/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ runDecodeIO (Decode dec) bs = do
embedIO :: IO a -> Decode a
embedIO action = Decode $ Peek $ \_ ptr -> do
v <- action
return (ptr, v)
pure (PeekResult ptr v)

{-# INLINE prim #-}
prim :: Int -> (Ptr Word8 -> IO a) -> Decode a
prim len f = Decode $ Peek $ \ps ptr -> do
!v <- f ptr
let !newPtr = ptr `plusPtr` len
return (newPtr, v)
-- return $ PeekResult newPtr v
pure (PeekResult newPtr v)

-- Public

Expand All @@ -54,16 +53,14 @@ getByteString :: Int -> Decode B.ByteString
getByteString len = Decode $ Peek $ \ps ptr -> do
bs <- B.packCStringLen (castPtr ptr, len)
let !newPtr = ptr `plusPtr` len
-- return $ PeekResult newPtr bs
return (newPtr, bs)
pure (PeekResult newPtr bs)

{-# INLINE getByteStringNull #-}
getByteStringNull :: Decode B.ByteString
getByteStringNull = Decode $ Peek $ \ps ptr -> do
bs <- B.packCString (castPtr ptr)
let !newPtr = ptr `plusPtr` (B.length bs + 1)
-- return $ PeekResult newPtr bs
return (newPtr, bs)
pure (PeekResult newPtr bs)

{-# INLINE getWord8 #-}
getWord8 :: Decode Word8
Expand Down Expand Up @@ -95,12 +92,12 @@ getInt64BE = fromIntegral <$> getWord64BE

{-# INLINE getFloat32BE #-}
getFloat32BE :: Decode Float
getFloat32BE = prim 4 $ \ptr -> byteSwap32 <$> peek (castPtr ptr)
getFloat32BE = prim 4 $ \ptr -> byteSwap32 <$> peek (castPtr ptr)
>>= wordToFloat

{-# INLINE getFloat64BE #-}
getFloat64BE :: Decode Double
getFloat64BE = prim 8 $ \ptr -> byteSwap64 <$> peek (castPtr ptr)
getFloat64BE = prim 8 $ \ptr -> byteSwap64 <$> peek (castPtr ptr)
>>= wordToFloat

{-# INLINE wordToFloat #-}
Expand Down
3 changes: 1 addition & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file was automatically generated by 'stack init'
#
resolver: lts-8.0
resolver: lts-8.21

packages:
- '.'
Expand All @@ -9,7 +9,6 @@ packages:
extra-deps:
- socket-0.8.0.0
- socket-unix-0.2.0.0
- store-core-0.3

# Override default flag values for local packages and extra-deps
flags: {}
Expand Down