PyF 0.9.0.1 → 0.9.0.2
raw patch · 9 files changed
+53/−51 lines, 9 filesdep ~megaparsecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: megaparsec
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- PyF.cabal +2/−4
- src/PyF/Internal/Extensions.hs +9/−8
- src/PyF/Internal/PythonSyntax.hs +4/−5
- src/PyF/Internal/QQ.hs +1/−1
- test/Spec.hs +21/−21
- test/SpecFail.hs +4/−3
- test/failureCases/bug18.hs +4/−5
- test/golden/2897849520519503487.golden +4/−4
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for PyF +## 0.9.0.2 -- 2020-09-11++- Version bump for megaparsec 9.0+ ## 0.9.0.1 -- 2020-03-25 - Fixs for GHC 8.10
PyF.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: PyF-version: 0.9.0.1+version: 0.9.0.2 synopsis: Quasiquotations for a python like interpolated string formater description: Quasiquotations for a python like interpolated string formater. license: BSD-3-Clause@@ -26,7 +26,7 @@ , containers -- Parsec and some transitive deps- , megaparsec >= 7.0 && < 9.0+ , megaparsec >= 7.0 && < 10.0 , mtl -- haskell-src-meta < 0.8.2 does not correctly handle TypeApplication@@ -42,7 +42,6 @@ hs-source-dirs: test main-is: Spec.hs other-modules: SpecUtils SpecCustomDelimiters- build-tools: python3 build-depends: base, PyF, hspec, text, template-haskell, process ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010@@ -59,7 +58,6 @@ type: exitcode-stdio-1.0 hs-source-dirs: test main-is: SpecFail.hs- build-tools: python3 build-depends: base, hspec, text, template-haskell, process, hspec, temporary, hashable, filepath, deepseq, directory, HUnit ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010
src/PyF/Internal/Extensions.hs view
@@ -8,11 +8,12 @@ -- | Associate a template haskell extension to an haskell-src-ext extension thExtToMetaExt :: TH.Extension -> Maybe Exts.Extension-thExtToMetaExt e = Exts.EnableExtension <$> case e of- -- For some reason, the casing is different between TH and haskell-src-exts- TH.Cpp -> Just Exts.CPP- -- Hope for the best, if haskell-src-ext knows the extension or not- _ -> case Exts.parseExtension (show e) of- Exts.EnableExtension ext -> Just ext- Exts.DisableExtension ext -> Just ext- Exts.UnknownExtension _ -> Nothing+thExtToMetaExt e =+ Exts.EnableExtension <$> case e of+ -- For some reason, the casing is different between TH and haskell-src-exts+ TH.Cpp -> Just Exts.CPP+ -- Hope for the best, if haskell-src-ext knows the extension or not+ _ -> case Exts.parseExtension (show e) of+ Exts.EnableExtension ext -> Just ext+ Exts.DisableExtension ext -> Just ext+ Exts.UnknownExtension _ -> Nothing
src/PyF/Internal/PythonSyntax.hs view
@@ -38,11 +38,10 @@ type Parser t = ParsecT Void String (Reader ParsingContext) t -data ParsingContext- = ParsingContext- { delimiters :: (Char, Char),- enabledExtensions :: [ParseExtension.Extension]- }+data ParsingContext = ParsingContext+ { delimiters :: (Char, Char),+ enabledExtensions :: [ParseExtension.Extension]+ } deriving (Show) {-
src/PyF/Internal/QQ.hs view
@@ -28,8 +28,8 @@ import GHC.TypeLits import Language.Haskell.TH import PyF.Class-import qualified PyF.Formatters as Formatters import PyF.Formatters (AnyAlign (..))+import qualified PyF.Formatters as Formatters import PyF.Internal.Extensions import PyF.Internal.PythonSyntax import Text.Megaparsec
test/Spec.hs view
@@ -193,25 +193,25 @@ it "E" $(checkExample "{1.0:#.0E}" "1.E+00") it "G" $(checkExample "{1.0:#.0G}" "1.") it "percent" $(checkExample "{1.0:#.0%}" "100.%")- describe "complex"- $ it "works with many things at once"- $ let name = "Guillaume"+ describe "complex" $+ it "works with many things at once" $+ let name = "Guillaume" age = 31 euroToFrancs = 6.55957 in [fmt|hello {name} you are {age} years old and the conversion rate of euro is {euroToFrancs:.2}|] `shouldBe` "hello Guillaume you are 31 years old and the conversion rate of euro is 6.56" describe "error reporting" $ pure () -- TODO: find a way to test error reporting- describe "sub expressions"- $ it "works"- $ [fmt|2pi = {2 * pi:.2}|] `shouldBe` "2pi = 6.28"- describe "escape strings"- $ it "works"- $ [fmt|hello \n\b|] `shouldBe` "hello \n\b"- describe "variable precision"- $ it "works"- $ do- let n = 3 :: Int- [fmt|{pi:.{n}}|] `shouldBe` "3.142"+ describe "sub expressions" $+ it "works" $+ [fmt|2pi = {2 * pi:.2}|] `shouldBe` "2pi = 6.28"+ describe "escape strings" $+ it "works" $+ [fmt|hello \n\b|] `shouldBe` "hello \n\b"+ describe "variable precision" $+ it "works" $+ do+ let n = 3 :: Int+ [fmt|{pi:.{n}}|] `shouldBe` "3.142" it "escape chars" $ [fmt|}}{{}}{{|] `shouldBe` "}{}{" describe "custom delimiters" $ do@@ -221,9 +221,9 @@ [myCustomFormatter|@@!!@@!!|] `shouldBe` "@!@!" it "works for custom precision" $ [myCustomFormatter|@pi:.@2!!|] `shouldBe` "3.14"- describe "empty line"- $ it "works"- $ [fmt||] `shouldBe` ""+ describe "empty line" $+ it "works" $+ [fmt||] `shouldBe` "" describe "multi line escape" $ do it "works" $ [fmt|\@@ -251,14 +251,14 @@ \ |] `shouldBe` "\\\n- a\n- b\n"- describe "empty trailing value"- $ it "String"- $ ( [fmt|\+ describe "empty trailing value" $+ it "String" $+ ( [fmt|\ {pi:.0} |] :: String )- `shouldBe` "3\n"+ `shouldBe` "3\n" describe "language extensions" $ do it "parses @Int" $ [fmt|hello {show @Int 10}|] `shouldBe` "hello 10"
test/SpecFail.hs view
@@ -110,9 +110,10 @@ failCompileContent :: HasCallStack => Int -> String -> String -> Spec failCompileContent h caption fileContent =- before (checkCompile fileContent) $ it (show caption) $ \res -> case res of- CompileError output -> golden (show h) output- _ -> assertFailure (show $ ".golden/" <> show h <> "\n" <> show res)+ before (checkCompile fileContent) $+ it (show caption) $ \res -> case res of+ CompileError output -> golden (show h) output+ _ -> assertFailure (show $ ".golden/" <> show h <> "\n" <> show res) main :: IO () main = hspec spec
test/failureCases/bug18.hs view
@@ -15,11 +15,10 @@ import qualified Data.Text as T import PyF -data Foo- = Foo- { fieldA :: (),- fieldB :: T.Text- }+data Foo = Foo+ { fieldA :: (),+ fieldB :: T.Text+ } deriving (Show) yolo :: Foo
test/golden/2897849520519503487.golden view
@@ -1,5 +1,5 @@ -INITIALPATH:27:3: error: [-Wmissing-fields, -Werror=missing-fields]+INITIALPATH:26:3: error: [-Wmissing-fields, -Werror=missing-fields] • Fields of ‘Foo’ not initialised: fieldA • In the expression: Foo {fieldB = (Data.String.fromString ("hello what's up " <> ((((PyF.Internal.QQ.formatAny PyF.Formatters.Minus) PyF.Internal.QQ.PaddingDefaultK) Nothing) Nothing) x))} In an equation for ‘yolo’:@@ -9,10 +9,10 @@ x :: T.Text x = T.pack "hi" |-27 | Foo+26 | Foo | ^^^... -INITIALPATH:34:1: error: [-Wmissing-signatures, -Werror=missing-signatures] Top-level binding with no type signature: main :: IO ()+INITIALPATH:33:1: error: [-Wmissing-signatures, -Werror=missing-signatures] Top-level binding with no type signature: main :: IO () |-34 | main = print yolo+33 | main = print yolo | ^^^^