From 2fdf04f54a2d4fe68068ebeb232624e3dcce24b7 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 3 Aug 2023 08:00:36 +0200 Subject: [PATCH] Remove leading carriage return in gql --- CHANGELOG.md | 5 +++++ graphql.cabal | 3 ++- src/Language/GraphQL/TH.hs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b37a40b..e615468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on and this project adheres to [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## [Unreleased] +### Fixed +- `gql` removes not only leading `\n` but also `\r`. + ## [1.2.0.1] - 2023-04-25 ### Fixed - Support hspec 2.11. @@ -508,6 +512,7 @@ and this project adheres to ### Added - Data types for the GraphQL language. +[Unreleased]: https://git.caraus.tech/OSS/graphql/compare/v1.2.0.1...master [1.2.0.1]: https://git.caraus.tech/OSS/graphql/compare/v1.2.0.0...v1.2.0.1 [1.2.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.1.0.0...v1.2.0.0 [1.1.0.0]: https://git.caraus.tech/OSS/graphql/compare/v1.0.3.0...v1.1.0.0 diff --git a/graphql.cabal b/graphql.cabal index 72f81e4..bcf69af 100644 --- a/graphql.cabal +++ b/graphql.cabal @@ -21,7 +21,8 @@ extra-source-files: CHANGELOG.md README.md tested-with: - GHC == 9.2.5 + GHC == 9.2.8, + GHC == 9.6.2 source-repository head type: git diff --git a/src/Language/GraphQL/TH.hs b/src/Language/GraphQL/TH.hs index b6bc18c..8e1fcb3 100644 --- a/src/Language/GraphQL/TH.hs +++ b/src/Language/GraphQL/TH.hs @@ -21,7 +21,7 @@ stripIndentation code = reverse indent count (' ' : xs) = indent (count - 1) xs indent _ xs = xs withoutLeadingNewlines = dropNewlines code - dropNewlines = dropWhile (== '\n') + dropNewlines = dropWhile $ flip any ['\n', '\r'] . (==) spaces = length $ takeWhile (== ' ') withoutLeadingNewlines -- | Removes leading and trailing newlines. Indentation of the first line is