From 1e6088ab9a53f49e8a6149375a02060b90d8a6e2 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Fri, 3 Jan 2020 09:47:19 +0100 Subject: [PATCH] Allow newlines in 'import' spacing to allow nice multiline imports and avoid inelegant too long lines --- CHANGELOG.md | 4 ++++ SJW.cabal | 2 +- src/Module/Imports.hs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce5f91..385637c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for SJW +## 0.1.1.0 -- 2020-01-03 + +* Imports can now span several lines + ## 0.1.0.0 -- 2020-01-01 * First working version with a small example diff --git a/SJW.cabal b/SJW.cabal index 9ada014..c8aa2c6 100644 --- a/SJW.cabal +++ b/SJW.cabal @@ -3,7 +3,7 @@ cabal-version: >=1.10 -- further documentation, see http://haskell.org/cabal/users-guide/ name: SJW -version: 0.1.0.0 +version: 0.1.1.0 synopsis: The Simple Javascript Wrench is a very simple tool to pack several JS «modules» into a single script. -- description: homepage: https://git.marvid.fr/Tissevert/SJW diff --git a/src/Module/Imports.hs b/src/Module/Imports.hs index 3df4625..c548609 100644 --- a/src/Module/Imports.hs +++ b/src/Module/Imports.hs @@ -42,7 +42,7 @@ recurse f initValue = recAux [] initValue foldlWithKey (\a k b -> recAux (k:stack) a b) nextValue (children tree) space :: Parser () -space = takeWhile (inClass " \t") *> pure () +space = takeWhile (inClass " \t\r\n") *> pure () between :: Parser a -> (Parser b, Parser c) -> Parser a between p (left, right) = left *> space *> p <* space <* right