madlang 2.3.0.6 → 2.3.1.0
raw patch · 6 files changed
+73/−30 lines, 6 filesdep +dhallPVP ok
version bump matches the API change (PVP)
Dependencies added: dhall
API changes (from Hackage documentation)
Files
- bench/Bench.hs +2/−2
- demo/example.mad +1/−1
- madlang.cabal +8/−7
- src/Text/Madlibs/Ana/ParseUtils.hs +2/−2
- src/Text/Madlibs/Exec/Main.hs +24/−14
- stack.yaml +36/−4
bench/Bench.hs view
@@ -34,6 +34,6 @@ [ bench "fortune-teller" $ whnf fun file , bench "shakespeare" $ whnf fun file2 ] , bgroup "run"- [ bench "shakespeare" $ whnfIO runTest- , bench "shakespeare-qq" $ whnfIO runTest ]+ [ bench "shakespeare" $ nfIO runTest+ , bench "shakespeare-qq" $ nfIO runTest ] ]
demo/example.mad view
@@ -39,4 +39,4 @@ 6.0 subject predicate :return 1.0 final- 0.02 final.oulipo+ 0.02 final.oulipo # removes all mentions of the letter 'e' a small amount of the time
madlang.cabal view
@@ -1,13 +1,13 @@ name: madlang-version: 2.3.0.6+version: 2.3.1.0 synopsis: Randomized templating language DSL description: Please see README.md homepage: https://github.com/vmchale/madlang#readme license: BSD3 license-file: LICENSE author: Vanessa McHale-maintainer: tmchale@wisc.edu-copyright: Copyright: (c) 2016 Vanessa McHale+maintainer: vanessa.mchale@reconfigure.io+copyright: Copyright: (c) 2016-2017 Vanessa McHale category: Web build-type: Simple stability: experimental@@ -57,6 +57,7 @@ , template-haskell , MonadRandom , composition+ , dhall , directory , file-embed , random-shuffle@@ -82,11 +83,11 @@ hs-source-dirs: app main-is: Main.hs if flag(llvm-fast)- ghc-options: -fllvm -O3 -optlo-O3 + ghc-options: -fllvm -O3 -optlo-O3 -opta-march=native -opta-mtune=native if flag(gold) ghc-options: -optl-fuse-ld=gold ld-options: -fuse-ld=gold- ghc-options: -threaded -rtsopts -with-rtsopts=-N + ghc-options: -threaded -rtsopts build-depends: base , madlang default-language: Haskell2010@@ -127,5 +128,5 @@ default-language: Haskell2010 source-repository head- type: git- location: https://github.com/vmchale/madlang+ type: darcs+ location: https://hub.darcs.net/vmchale/madlang
src/Text/Madlibs/Ana/ParseUtils.hs view
@@ -95,6 +95,6 @@ orderKeys (key1, l1) (key2, l2) | key1 == "Return" = GT | key2 == "Return" = LT- | any (\pair -> any (T.isInfixOf key1) (map unTok . snd $ pair)) l1 = GT- | any (\pair -> any (T.isInfixOf key2) (map unTok . snd $ pair)) l1 = LT+ | any (\pair -> any (== key1) (map unTok . snd $ pair)) l2 = LT+ | any (\pair -> any (== key2) (map unTok . snd $ pair)) l1 = GT | otherwise = EQ
src/Text/Madlibs/Exec/Main.hs view
@@ -17,25 +17,20 @@ import Data.Version -- | datatype for the program-data Program = Program { sub :: Subcommand - , input :: FilePath - }+data Program = Program { sub :: Subcommand } -- | datatype for the subcommands-data Subcommand = Debug- | Run { rep :: Maybe Int , clInputs :: [String] }- | Lint { clInputs :: [String] }+data Subcommand = Debug { input :: FilePath }+ | Run { rep :: Maybe Int , clInputs :: [String] , input :: FilePath }+ | Lint { clInputs :: [String] , input :: FilePath } -- | Parser for command-line options for the program orders :: Parser Program orders = Program <$> (hsubparser (command "run" (info temp (progDesc "Generate text from a .mad file"))- <> command "debug" (info (pure Debug) (progDesc "Debug a template"))+ <> command "debug" (info debug (progDesc "Debug a template")) <> command "lint" (info lint (progDesc "Lint a file"))))- <*> (argument str- (metavar "FILEPATH"- <> help "File path to madlang template")) -- | Parser for the run subcommand temp :: Parser Subcommand@@ -49,7 +44,18 @@ (short 'i' <> metavar "VAR" <> help "command-line inputs to the template."))+ <*> (argument str+ (metavar "FILEPATH"+ <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")+ <> help "File path to madlang template")) +debug :: Parser Subcommand+debug = Debug+ <$> (argument str+ (metavar "FILEPATH"+ <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")+ <> help "File path to madlang template"))+ -- | Parser for the lint subcommand lint :: Parser Subcommand lint = Lint@@ -57,6 +63,10 @@ (short 'i' <> metavar "VAR" <> help "command-line inputs to the template."))+ <*> (argument str+ (metavar "FILEPATH"+ <> completer (bashCompleter "file -X '!*.mad' -o plusdirs")+ <> help "File path to madlang template")) -- | Main program action --@@ -78,15 +88,15 @@ -- | given a parsed record perform the appropriate IO action template :: Program -> IO () template rec = do- let toFolder = input rec+ let toFolder = input . sub $ rec if getDir toFolder == "" then pure () else setCurrentDirectory (getDir toFolder) let filepath = reverse . (takeWhile (/='/')) . reverse $ toFolder let ins = map T.pack (clInputs . sub $ rec) case sub rec of- (Run reps _) -> do+ (Run reps _ _) -> do parsed <- parseFile ins "" filepath replicateM_ (fromMaybe 1 reps) $ runFile ins filepath >>= TIO.putStrLn - Debug -> putStr . (either show displayTree) =<< makeTree ins "" filepath - (Lint _) -> do+ (Debug _) -> putStr . (either show displayTree) =<< makeTree ins "" filepath + (Lint _ _) -> do parsed <- parseFile ins "" filepath putStrLn $ either parseErrorPretty (const "No syntax errors found.") parsed
stack.yaml view
@@ -1,6 +1,38 @@-flags: {}-extra-package-dbs: []+resolver: lts-8.19 packages:-- '.'+ - .+ - extra-dep: true+ location:+ git: https://github.com/haskell/deepseq+ commit: 0b22c9825ef79c1ee41d2f19e7c997f5cdc93494+ - extra-dep: true+ location:+ git: https://github.com/ekmett/semigroupoids.git+ commit: c3297f970658ae874db098190327ec742044a2e6+ - extra-dep: true+ location:+ git: http://github.com/ekmett/lens.git+ commit: 7031e00f62a704a86c3149c75c1e2afc059af022+ - extra-dep: true+ location:+ git: https://github.com/ekmett/trifecta.git+ commit: ea93f257e18e14699f8872a88bfd444c73df9155+flags:+ madlang:+ llvm-fast: true extra-deps:-resolver: lts-8.12+- dhall-1.4.2+allow-newer: true+compiler: ghc-8.2.0.20170507+compiler-check: match-exact+setup-info:+ ghc:+ linux64:+ 8.2.0.20170507:+ url: https://downloads.haskell.org/~ghc/8.2.1-rc2/ghc-8.2.0.20170507-x86_64-deb8-linux.tar.xz+ macosx:+ 8.2.0.20170507:+ url: https://downloads.haskell.org/~ghc/8.2.1-rc2/ghc-8.2.0.20170507-x86_64-apple-darwin.tar.xz+ windows64:+ 8.2.0.20170507:+ url: https://downloads.haskell.org/~ghc/8.2.1-rc2/ghc-8.2.0.20170507-x86_64-unknown-mingw32.tar.xz