Skip to content

Update to LTS-19.18 and Aeson 2.x compatibility #122

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

Closed
wants to merge 4 commits into from
Closed
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 aws-lambda-haskell-runtime.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: aws-lambda-haskell-runtime
version: 4.1.1
version: 4.1.2
synopsis: Haskell runtime for AWS Lambda
description: Please see the README on GitHub at <https://github.com/theam/aws-lambda-haskell-runtime#readme>
category: AWS
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: aws-lambda-haskell-runtime
version: 4.1.1
version: 4.1.2
github: "theam/aws-lambda-haskell-runtime"
license: Apache-2.0
author: Nikita Tchayka
Expand Down
8 changes: 5 additions & 3 deletions src/Aws/Lambda/Runtime/ALB/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import Data.Aeson
KeyValue ((.=)),
Object,
ToJSON (toJSON),
Key,
Value (Null, Object, String),
eitherDecodeStrict,
object,
(.:),
)
import Data.Aeson.Types (Parser)
import Data.Aeson.Key (fromText)
import qualified Data.Aeson.Types as T
import qualified Data.CaseInsensitive as CI
import Data.HashMap.Strict (HashMap)
Expand Down Expand Up @@ -59,7 +61,7 @@ instance FromJSON body => FromJSON (ALBRequest body) where
parseJSON = parseALBRequest parseObjectFromStringField

-- We need this because API Gateway is going to send us the payload as a JSON string
parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a)
parseObjectFromStringField :: FromJSON a => Object -> Key -> Parser (Maybe a)
parseObjectFromStringField obj fieldName = do
fieldContents <- obj .: fieldName
case fieldContents of
Expand All @@ -70,7 +72,7 @@ parseObjectFromStringField obj fieldName = do
Null -> pure Nothing
other -> T.typeMismatch "String or Null" other

parseALBRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body)
parseALBRequest :: (Object -> Key -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body)
parseALBRequest bodyParser (Object v) =
ALBRequest
<$> v .: "path"
Expand Down Expand Up @@ -167,5 +169,5 @@ mkALBResponse code headers payload =
headerToPair :: Header -> T.Pair
headerToPair (cibyte, bstr) = k .= v
where
k = (T.decodeUtf8 . CI.original) cibyte
k = fromText $ (T.decodeUtf8 . CI.original) cibyte
v = T.decodeUtf8 bstr
8 changes: 5 additions & 3 deletions src/Aws/Lambda/Runtime/APIGateway/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import Data.Aeson
KeyValue ((.=)),
Object,
ToJSON (toJSON),
Key,
Value (Null, Object, String),
eitherDecodeStrict,
object,
(.:),
(.:?)
)
import Data.Aeson.Types (Parser)
import Data.Aeson.Key (fromText)
import qualified Data.Aeson.Types as T
import qualified Data.CaseInsensitive as CI
import Data.HashMap.Strict (HashMap)
Expand Down Expand Up @@ -70,7 +72,7 @@ instance FromJSON body => FromJSON (ApiGatewayRequest body) where
parseJSON = parseApiGatewayRequest parseObjectFromStringField

-- We need this because API Gateway is going to send us the payload as a JSON string
parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a)
parseObjectFromStringField :: FromJSON a => Object -> Key -> Parser (Maybe a)
parseObjectFromStringField obj fieldName = do
fieldContents <- obj .: fieldName
case fieldContents of
Expand All @@ -81,7 +83,7 @@ parseObjectFromStringField obj fieldName = do
Null -> pure Nothing
other -> T.typeMismatch "String or Null" other

parseApiGatewayRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body)
parseApiGatewayRequest :: (Object -> Key -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body)
parseApiGatewayRequest bodyParser (Object v) =
ApiGatewayRequest
<$> v .: "resource"
Expand Down Expand Up @@ -215,5 +217,5 @@ mkApiGatewayResponse code headers payload =
headerToPair :: Header -> T.Pair
headerToPair (cibyte, bstr) = k .= v
where
k = (T.decodeUtf8 . CI.original) cibyte
k = fromText $ (T.decodeUtf8 . CI.original) cibyte
v = T.decodeUtf8 bstr
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-16.12
resolver: lts-19.24

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ packages:
hackage: megaparsec-7.0.5@sha256:45e1f1348fab2783646fdb4d9e6097568981a740951c7356d36d794e2baba305,3902
snapshots:
- completed:
size: 532377
url: https://github.com/raw/commercialhaskell/stackage-snapshots/master/lts/16/12.yaml
sha256: f914cfa23fef85bdf895e300a8234d9d0edc2dbec67f4bc9c53f85867c50eab6
original: lts-16.12
size: 619403
url: https://github.com/raw/commercialhaskell/stackage-snapshots/master/lts/19/24.yaml
sha256: 98f5bee5bf07ff25263d7061e03c34595bfca543b611f9d3da5c95f2a6c8d723
original: lts-19.24