packages feed

madlang 4.0.2.0 → 4.0.2.1

raw patch · 4 files changed

+4/−19 lines, 4 filesdep −recursion-schemes-ext

Dependencies removed: recursion-schemes-ext

Files

madlang.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: madlang-version: 4.0.2.0+version: 4.0.2.1 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2016-2018 Vanessa McHale@@ -72,7 +72,6 @@         file-embed -any,         random-shuffle -any,         mtl -any,-        recursion-schemes-ext >=1.0.0.3,         ansi-wl-pprint -any,         containers -any,         titlecase >=1.0,
man/madlang.1 view
@@ -1,4 +1,4 @@-.\" Automatically generated by Pandoc 2.1.1+.\" Automatically generated by Pandoc 2.1.3 .\" .TH "madlang (1)" "" "" "" "" .hy
src/Text/Madlibs.hs view
@@ -29,7 +29,6 @@                     , makeTree                     -- * Functions and constructs for the `RandTok` data type                     , run-                    , runCata                     , runText                     , RandTok (..)                     , Key
src/Text/Madlibs/Cata/Run.hs view
@@ -1,10 +1,9 @@ -- | Module containing functions to get `Text` from `RandTok` module Text.Madlibs.Cata.Run ( run-                             , runCata ) where+                             ) where  import           Control.Monad.Random.Class-import           Data.Functor.Foldable.Exotic (cataM)-import qualified Data.Text                    as T+import qualified Data.Text                   as T import           Text.Madlibs.Internal.Types import           Text.Madlibs.Internal.Utils @@ -25,19 +24,7 @@         tokNest@List{} -> run tokNest run (Value txt) = pure txt --- | Same thing, but uses a catamorphism (slower)-runCata :: (MonadRandom m) => RandTok -> m T.Text-runCata = cataM alg where-    alg (ListF tok) = do-        value <- getRandomR (0,1)-        pure $ ((snd . head) . filter ((>= value) . fst)) $ mkCdfCata tok-    alg (ValueF txt) = pure txt- -- | Helper function to compute the cdf when we have a pdf mkCdf :: RandTok -> [(Prob, RandTok)] mkCdf (List rs) = zip (cdf . fmap fst $ rs) (fmap snd rs) mkCdf v@Value{} = [(1, v)]---- | Another helper function, this time for use with our catamorphism.-mkCdfCata :: [(Prob, T.Text)] -> [(Prob, T.Text)]-mkCdfCata rs = zip (cdf . fmap fst $ rs) (fmap snd rs)