packages feed

madlang 2.1.2.0 → 2.2.0.1

raw patch · 5 files changed

+11/−11 lines, 5 filesdep +MonadRandomdep −mwc-randomPVP ok

version bump matches the API change (PVP)

Dependencies added: MonadRandom

Dependencies removed: mwc-random

API changes (from Hackage documentation)

- Text.Madlibs: run :: RandTok -> IO Text
+ Text.Madlibs: run :: (MonadRandom m) => RandTok -> m Text
- Text.Madlibs: runText :: [Text] -> String -> Text -> IO Text
+ Text.Madlibs: runText :: (MonadRandom m) => [Text] -> String -> Text -> m Text

Files

default.nix view
@@ -4,7 +4,7 @@ }: mkDerivation {   pname = "madlang";-  version = "2.1.1.2";+  version = "2.2.0.0";   src = ./.;   isLibrary = true;   isExecutable = true;
madlang.cabal view
@@ -1,5 +1,5 @@ name:                madlang-version:             2.1.2.0+version:             2.2.0.1 synopsis:            Randomized templating language DSL description:         Please see README.md homepage:            https://github.com/vmchale/madlang#readme@@ -41,10 +41,10 @@   build-depends:       base >= 4.7 && < 5                      , megaparsec                      , text-                     , optparse-applicative +                     , optparse-applicative+                     , MonadRandom                      , composition                      , directory-                     , mwc-random                      , random-shuffle                      , microlens                      , mtl
src/Text/Madlibs/Ana/Resolve.hs view
@@ -17,6 +17,7 @@ import Data.Monoid import Control.Applicative import Control.Monad+import Control.Monad.Random.Class  -- | Parse a template file into the `RandTok` data type parseFile :: [T.Text] -- ^ variables to substitute into the template@@ -47,7 +48,7 @@ runInFolder = ((either (pure . parseErrorPretty') (>>= (pure . show'))) =<<) .** (fmap (fmap run) .** parseFile)  -- | Run based on text input, with nothing linked.-runText :: [T.Text] -> String -> T.Text -> IO T.Text+runText :: (MonadRandom m) => [T.Text] -> String -> T.Text -> m T.Text runText vars name = (either (pure . parseErrorPretty') id) . (fmap run) . (parseTok name [] vars)  -- | Get file as context
src/Text/Madlibs/Cata/Run.hs view
@@ -4,12 +4,12 @@ import Text.Madlibs.Internal.Types import Text.Madlibs.Internal.Utils import qualified Data.Text as T-import System.Random.MWC+import Control.Monad.Random.Class  -- | Generate randomized text from a `RandTok`-run :: RandTok -> IO T.Text+run :: (MonadRandom m) => RandTok -> m T.Text run tok@(List rs) = do-    value <-(withSystemRandom . asGenST $ \gen -> uniform gen)+    value <- getRandomR (0,1) --(withSystemRandom . asGenST $ \gen -> uniform gen)     let ret = ((snd . head) . filter ((>=value) . fst)) $ mkCdf tok     case ret of         (Value txt) -> pure txt
src/Text/Madlibs/Cata/SemErr.hs view
@@ -70,9 +70,8 @@ --do we need this all in a monad?? -- | big semantics checker that sequences stuff checkSemantics :: [(Key, [(Prob, [PreTok])])] -> Parser [(Key, [(Prob, [PreTok])])]-checkSemantics keys = foldr (<=<) pure ((checkKey "Return"):[checkKey key | key <- allKeys keys ])-                                       $ keys-    where allKeys = fmap name . (concatMap snd) . (concatMap snd) -- TODO use a traversal here!!+checkSemantics keys = foldr (<=<) pure ((checkKey "Return"):[checkKey key | key <- allKeys keys ]) $ keys+    where allKeys = fmap name . (concatMap snd) . (concatMap snd)--traversal?           name (Name str _) = str           name (PreTok _) = "Return"