madlang 2.3.1.1 → 2.3.2.0
raw patch · 5 files changed
+30/−13 lines, 5 filesdep +composition-extraPVP ok
version bump matches the API change (PVP)
Dependencies added: composition-extra
API changes (from Hackage documentation)
Files
- default.nix +5/−5
- madlang.cabal +2/−1
- src/Text/Madlibs/Ana/Parse.hs +1/−1
- src/Text/Madlibs/Ana/ParseUtils.hs +14/−2
- stack.yaml +8/−4
default.nix view
@@ -1,18 +1,18 @@ { mkDerivation, ansi-wl-pprint, base, composition, containers-, dhall, directory, file-embed, hspec, hspec-megaparsec, megaparsec+, directory, file-embed, hspec, hspec-megaparsec, megaparsec , microlens, MonadRandom, mtl, optparse-applicative, random-shuffle , stdenv, template-haskell, text }: mkDerivation { pname = "madlang";- version = "2.3.1.0";+ version = "2.3.1.1"; src = ./.; isLibrary = true; isExecutable = true; libraryHaskellDepends = [- ansi-wl-pprint base composition containers dhall directory- file-embed megaparsec microlens MonadRandom mtl- optparse-applicative random-shuffle template-haskell text+ ansi-wl-pprint base composition containers directory file-embed+ megaparsec microlens MonadRandom mtl optparse-applicative+ random-shuffle template-haskell text ]; executableHaskellDepends = [ base ]; testHaskellDepends = [
madlang.cabal view
@@ -1,5 +1,5 @@ name: madlang-version: 2.3.1.1+version: 2.3.2.0 synopsis: Randomized templating language DSL description: Please see README.md homepage: https://github.com/vmchale/madlang#readme@@ -57,6 +57,7 @@ , template-haskell , MonadRandom , composition+ , composition-extra -- , dhall , directory , file-embed
src/Text/Madlibs/Ana/Parse.hs view
@@ -83,7 +83,7 @@ modifier :: Parser (T.Text -> T.Text) modifier = do char '.'- str <- foldr (<|>) (pure "") $ map (try . string) ["to_upper", "to_lower", "reverse", "reverse_words", "oulipo"]+ str <- foldr (<|>) (pure "") $ map (try . string) ["to_upper", "to_lower", "reverse", "reverse_words", "oulipo", "capitalize"] pure (fromMaybe id (M.lookup str modifierList)) <?> "modifier" -- | Parse template into a `PreTok` of referents and strings
src/Text/Madlibs/Ana/ParseUtils.hs view
@@ -19,14 +19,20 @@ import System.Random.Shuffle import qualified Data.Map as M import Data.Char+import Data.Monoid+import Data.Function.Contravariant.Syntax import Control.Monad.Random.Class --TODO consider moving Ana.ParseUtils to Cata.Sorting +(&) :: a -> (a -> b) -> b+(&) x f = f x+ -- | A map with all the modifiers we modifierList :: M.Map String (T.Text -> T.Text) modifierList = M.fromList [("to_upper", T.map toUpper) , ("to_lower", T.map toLower)+ , ("capitalize", (\t -> toUpper (T.head t) `T.cons` T.tail t)) , ("reverse", T.reverse) , ("reverse_words", T.unwords . reverse . T.words) , ("oulipo", T.filter (/='e'))]@@ -95,6 +101,12 @@ orderKeys (key1, l1) (key2, l2) | key1 == "Return" = GT | key2 == "Return" = LT- | any (\pair -> any (== key1) (map unTok . snd $ pair)) l2 = LT- | any (\pair -> any (== key2) (map unTok . snd $ pair)) l1 = GT+ | any (\pair -> {--hyphenList key1 (map unTok . snd $ pair) ||--} key1 `elem` (map unTok . snd $ pair)) l2 = LT+ | any (\pair -> {--hyphenList key2 (map unTok . snd $ pair) ||--} key2 `elem` (map unTok . snd $ pair)) l1 = GT | otherwise = EQ++hyphenList :: T.Text -> [T.Text] -> Bool+hyphenList s1 = any (flip hyphenSuffix s1)++hyphenSuffix :: T.Text -> T.Text -> Bool+hyphenSuffix = ("-" <>) -.* T.isSuffixOf
stack.yaml view
@@ -13,15 +13,19 @@ location: git: http://github.com/ekmett/lens.git commit: 7031e00f62a704a86c3149c75c1e2afc059af022+ #- extra-dep: true+ #location:+ # git: https://github.com/ekmett/trifecta.git+ # commit: ea93f257e18e14699f8872a88bfd444c73df9155 - extra-dep: true location:- git: https://github.com/ekmett/trifecta.git- commit: ea93f257e18e14699f8872a88bfd444c73df9155+ git: https://github.com/dreixel/syb.git+ commit: f584ecd525179778063df2eb02dc6bbe406d7e75 flags: madlang: llvm-fast: true-extra-deps:-- dhall-1.4.2+#extra-deps:+#- dhall-1.4.2 allow-newer: true compiler: ghc-8.2.0.20170507 compiler-check: match-exact