madlang 4.0.2.2 → 4.0.2.5
raw patch · 6 files changed
+9/−8 lines, 6 files
Files
- README.md +1/−0
- app/Main.hs +1/−1
- demo/bi-update.mad +1/−1
- madlang.cabal +1/−1
- man/madlang.1 +2/−2
- src/Text/Madlibs/Ana/Resolve.hs +3/−3
README.md view
@@ -2,6 +2,7 @@ [](https://ci.appveyor.com/project/vmchale/madlang) [](https://travis-ci.org/vmchale/madlang)+[](http://hackage.haskell.org/package/madlang) This is the Madlang DSL for generating text. You specify a template, and Madlang will create randomized text from the template.
app/Main.hs view
@@ -127,5 +127,5 @@ (Debug _) -> putStr . either show displayTree =<< makeTree ins "" filepath (Lint _ _) -> do parsed <- parseFile ins "" filepath- putStrLn $ either parseErrorPretty (const "No syntax errors found.") parsed+ putStrLn $ either parseErrorPretty (pure "No syntax errors found.") parsed _ -> pure ()
demo/bi-update.mad view
@@ -1,5 +1,5 @@ # inspired by https://twitter.com/biupdatebot-# install libraries with `madlang install` if necessary.+# install libraries with `madlang install` before running. :include adverbs.mad :return
madlang.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: madlang-version: 4.0.2.2+version: 4.0.2.5 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2016-2018 Vanessa McHale
man/madlang.1 view
@@ -98,8 +98,8 @@ https://hub.darcs.net/vmchale/madlang\-insults. .SH COPYRIGHT .PP-Copyright 2017.+Copyright 2017\-2018. Vanessa McHale. All Rights Reserved. .SH AUTHORS-Vanessa McHale<vanessa.mchale@reconfigure.io>.+Vanessa McHale<vamchale@gmail.com>.
src/Text/Madlibs/Ana/Resolve.hs view
@@ -42,14 +42,14 @@ getInclusionCtx :: (MonadIO m) => Bool -> [T.Text] -> FilePath -> FilePath -> m (Either (ParseError Char (ErrorFancy Void)) [(Key, RandTok)]) getInclusionCtx isTree ins folder filepath = liftIO $ do libDir <- do { home <- getEnv "HOME" ; pure (home <> (pathSep : ".madlang" <> pure pathSep)) }- file <- catch (readFile' (folder ++ filepath)) (const (readLibFile (libDir <> folder <> filepath)) :: IOException -> IO T.Text)+ file <- catch (readFile' (folder ++ filepath)) (pure (readLibFile (libDir <> folder <> filepath)) :: IOException -> IO T.Text) let filenames = map T.unpack $ either (error . show) id $ parseInclusions filepath file -- TODO pass up errors correctly let resolveKeys file' = fmap (first (((T.pack . (<> "-")) . dropExtension) file' <>)) ctxPure <- mapM (getInclusionCtx isTree ins folder) filenames let ctx = zipWith resolveKeys filenames <$> sequence ctxPure catch- (parseCtx isTree ins (concat . either (const []) id $ ctx) (folder ++ filepath))- (const (do { home <- getEnv "HOME" ; parseCtx isTree ins (concat . either (const []) id $ ctx) (home <> (pathSep : ".madlang") <> [pathSep] <> folder <> filepath) }) :: IOException -> IO (Either (ParseError Char (ErrorFancy Void)) [(Key, RandTok)]))+ (parseCtx isTree ins (mconcat . either (pure []) id $ ctx) (folder ++ filepath))+ (pure (do { home <- getEnv "HOME" ; parseCtx isTree ins (mconcat . either (pure []) id $ ctx) (home <> (pathSep : ".madlang") <> [pathSep] <> folder <> filepath) }) :: IOException -> IO (Either (ParseError Char (ErrorFancy Void)) [(Key, RandTok)])) pathSep :: Char pathSep | os == "windows" = '\\'