packages feed

nyan-interpolation 0.9 → 0.9.1

raw patch · 5 files changed

+112/−21 lines, 5 filesdep +spoondep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: spoon

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

nyan-interpolation.cabal view
@@ -1,13 +1,13 @@ cabal-version: 2.0 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.35.0. -- -- see: https://github.com/sol/hpack ----- hash: 191c85a1a5dfccaa3abfb718b94a0a57cdb576f10a674129e73519fc12ed58c6+-- hash: a77f2eae2cfd2c173f77963a2f6af54c0547b52b2841f478fa358fb6756a163c  name:           nyan-interpolation-version:        0.9+version:        0.9.1 synopsis:       Flexible production-scale string interpolation library description:    Interpolation library tuneable to your project and your best practices. It supports custom rendering (via Buildable, Show), numerious modification options (like spaces and indentation stripping), and more. category:       Interpolation, Text@@ -36,14 +36,45 @@       Paths_nyan_interpolation   hs-source-dirs:       src-  default-extensions: AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveGeneric DerivingStrategies FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns OverloadedStrings RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeFamilies UndecidableInstances ViewPatterns TypeApplications TypeOperators QuasiQuotes+  default-extensions:+      AllowAmbiguousTypes+      BangPatterns+      BlockArguments+      ConstraintKinds+      DataKinds+      DefaultSignatures+      DeriveDataTypeable+      DeriveGeneric+      DerivingStrategies+      FlexibleContexts+      FlexibleInstances+      FunctionalDependencies+      GeneralizedNewtypeDeriving+      LambdaCase+      MultiParamTypeClasses+      MultiWayIf+      NamedFieldPuns+      OverloadedStrings+      RankNTypes+      RecordWildCards+      ScopedTypeVariables+      StandaloneDeriving+      TemplateHaskell+      TupleSections+      TypeFamilies+      UndecidableInstances+      ViewPatterns+      TypeApplications+      TypeOperators+      QuasiQuotes   ghc-options: -Weverything -Wno-missing-export-lists -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-implicit-prelude -Wno-prepositive-qualified-module -Wno-missing-safe-haskell-mode -Wno-unused-packages   build-depends:-      base <4.15+      base <4.17     , fmt     , haskell-src-exts     , haskell-src-meta     , nyan-interpolation-core+    , spoon     , template-haskell     , text   default-language: Haskell2010@@ -56,20 +87,53 @@       Test.ShowInterpolator       Tree       Paths_nyan_interpolation+  autogen-modules:+      Paths_nyan_interpolation   hs-source-dirs:       tests-  default-extensions: AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveGeneric DerivingStrategies FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns OverloadedStrings RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeFamilies UndecidableInstances ViewPatterns TypeApplications TypeOperators QuasiQuotes+  default-extensions:+      AllowAmbiguousTypes+      BangPatterns+      BlockArguments+      ConstraintKinds+      DataKinds+      DefaultSignatures+      DeriveDataTypeable+      DeriveGeneric+      DerivingStrategies+      FlexibleContexts+      FlexibleInstances+      FunctionalDependencies+      GeneralizedNewtypeDeriving+      LambdaCase+      MultiParamTypeClasses+      MultiWayIf+      NamedFieldPuns+      OverloadedStrings+      RankNTypes+      RecordWildCards+      ScopedTypeVariables+      StandaloneDeriving+      TemplateHaskell+      TupleSections+      TypeFamilies+      UndecidableInstances+      ViewPatterns+      TypeApplications+      TypeOperators+      QuasiQuotes   ghc-options: -Weverything -Wno-missing-export-lists -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-implicit-prelude -Wno-prepositive-qualified-module -Wno-missing-safe-haskell-mode -Wno-unused-packages   build-tool-depends:       tasty-discover:tasty-discover   build-depends:       HUnit-    , base <4.15+    , base <4.17     , fmt     , haskell-src-exts     , haskell-src-meta     , nyan-interpolation     , nyan-interpolation-core+    , spoon     , tasty     , tasty-hunit-compat     , template-haskell
src/Text/Interpolation/Nyan.hs view
@@ -76,8 +76,9 @@ * Aside from 'Formatting.Buildable.Buildable' and 'Show' support, one can define their own so-called /rendering modes/. * The existing rendering modes can be hidden or grouped into modesets.-  For instance, there is a modeset with 'Show' taken as the default rendering-  mode; it is used as the basic modeset in "Text.Interpolation.Nyan.Show" module.+  For instance, there is a modeset "Text.Interpolation.Nyan.RModes.Show" with+  'Show' taken as the default rendering mode; it is used as the basic modeset in+  "Text.Interpolation.Nyan.Show" module. * The set of switches enabled by default is also customizable.  Generally, once the user gets comfortable with the library, we encourage them
src/Text/Interpolation/Nyan/Full.hs view
@@ -19,6 +19,9 @@ import Language.Haskell.TH (extsEnabled)  #if MIN_VERSION_haskell_src_meta(0,8,9)+import Control.Exception (Handler (..), PatternMatchFail (..))+import Control.Monad (join)+import Control.Spoon (teaspoonWithHandles) import Data.Maybe (mapMaybe) import Language.Haskell.Exts.Extension (Extension (..), Language (..)) import Language.Haskell.Exts.Parser (baseLanguage)@@ -38,8 +41,12 @@   for the interpolated values.   With the modern version of @haskell-src-meta@, we do our best to be trasparent   and pick the extensions enabled in the module where interpolator is called-  (some rare extensions may still be unsupported).+  (some rare extensions may still be unsupported since they are not represented+  in @haskell-src-exts@ or in @template-haskell@ packages). +* Some very modern extensions might be not allowed; if you face such issue,+  try using the most recent version of @haskell-src-meta@.+ -} fullHaskellValueInterpolator :: ValueInterpolator fullHaskellValueInterpolator = ValueInterpolator $ \txt -> do@@ -61,7 +68,18 @@   where     providedExtensions = #if MIN_VERSION_haskell_src_meta(0,8,9)-      map EnableExtension . mapMaybe fromExtension+      -- There is a period of time when fromExtension didn't handle+      -- some cases in its pattern match.+      -- See https://github.com/haskell-party/haskell-src-meta/issues/40+      --+      -- If some extension is unknown to it, we will just pretend it+      -- does not exist.+      let fromExtensionSafe ext =+            join . teaspoonWithHandles+              [Handler \(_ :: PatternMatchFail) -> pure Nothing] $+              fromExtension ext++      in map EnableExtension . mapMaybe fromExtensionSafe #else       -- There is no easy way to do the conversion between template-haskell's       -- and haskell-src-exts's Extension types, so using only language-default
src/Text/Interpolation/Nyan/Tutorial.hs view
@@ -7,7 +7,7 @@  {- | Tutorial on the nyan-interpolation. ->>> import Nyan.Interpolation+>>> import Text.Interpolation.Nyan >>> >>> let who = "world" >>> in [int||Hello #{who}!|]@@ -24,7 +24,7 @@ * If multiline text is provided, its indentation, leading newline and trailing spaces are stripped:  >>> :{-  putStrLn [int||+  putStr [int||       Yay       Here goes         my text@@ -35,7 +35,6 @@ Here goes   my text and ends here.-<BLANKLINE>  Note that the module with interpolator is assumed to be imported with an implicit import list. This should not spoil your namespace, @int@ is the only@@ -157,7 +156,7 @@  ==== Z (no last line stripping) -Similarly to the previous option, by default he position of the trailing @|]@+Similarly to the previous option, by default the position of the trailing @|]@ does not affect the result. When the option is disabled via passing @Z@ switch, spaces at the last line will be preserved.@@ -205,7 +204,8 @@ To be stricter, this switch requires only @Applicative@ instance.  In case monadic actions have side effects, they will be applied in the same order-in which braces appear in the quoter. /But you are not going to use this behaviour, don't you?/+in which placeholders appear in the quoter. /But you are not going to use this+behaviour, don't you?/  ==== t (return [t]ext) @@ -225,7 +225,7 @@  ==== ! (preview) -Quoter will show as an error (non-blocking for the module's build) showing how the+Quoter will show as an error (non-blocking for the module's build) how the resulting text looks like with all the enabled switches (but without substitutions). @@ -292,7 +292,7 @@  int :: QuasiQuoter int = mkInt defaultInterpolationOptions-  { switchesOptions = basicDefaultSwitchesOptions+  { switchesOptions = recommendedDefaultSwitchesOptions     { spacesTrimming = True     , returnType = ConcreteText     }@@ -311,7 +311,8 @@  ==== Adding custom rendering modes -Rendering mode @xxx@ refers to whatever @rmode'xxx@ value that is available in scope.+Rendering mode @xxx@ refers to whatever @rmode'xxx@ value of type 'RMode' that+is available in scope.  For instance, the rendering mode for 'Show' is declared as @@ -330,7 +331,7 @@ >>> [int|t|Say #yay{"hello"}|] "Say *hello!*" -You can declare /modesets/ ⁠— modules that export several rendering modes.+Finally, you can declare /modesets/ ⁠— modules that export several rendering modes. The user can then easily pick all or some of the modes by importing that module.  -}@@ -341,4 +342,4 @@ import Fmt (Buildable, Builder) import Fmt.Internal.Core (FromBuilder) -import Text.Interpolation.Nyan.Core (mkInt)+import Text.Interpolation.Nyan.Core (mkInt, RMode)
tests/Test/Interpolator.hs view
@@ -31,4 +31,11 @@       [int|t|#d{succ . succ $ 5 + 7 `div` 2}|]         @?= "10" +  , -- We want to ensure that at least basic extensions work in the interpolator+    testGroup "Code with extensions works"+    [ testCase "TypeApplications works" do+        [int|t|#{id @Int 1}|]+          @?= "1"+    ]+   ]