madlang 1.0.0.1 → 1.0.1.0
raw patch · 7 files changed
+25/−11 lines, 7 filesdep ~hspecdep ~madlang
Dependency ranges changed: hspec, madlang
Files
- madlang.cabal +14/−5
- src/Text/Madlibs/Ana/Parse.hs +2/−2
- src/Text/Madlibs/Internal/Utils.hs +5/−0
- stack-8.yaml +1/−1
- stack-nightly.yaml +1/−1
- stack.yaml +1/−1
- test/Spec.hs +1/−1
madlang.cabal view
@@ -1,5 +1,5 @@ name: madlang-version: 1.0.0.1+version: 1.0.1.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -25,6 +25,11 @@ type: git location: https://github.com/vmchale/madlang +flag llvm-fast+ description:+ Enable build with llvm backend+ default: False+ library exposed-modules: Text.Madlibs@@ -52,21 +57,25 @@ Text.Madlibs.Exec.Main executable madlang+ + if flag(llvm-fast)+ ghc-options: -threaded -rtsopts -with-rtsopts=-N -fllvm -optlo-O3 -O3+ else+ ghc-options: -threaded -rtsopts -with-rtsopts=-N main-is: Main.hs build-depends: base >=4.9.1.0 && <4.10,- madlang >=1.0.0.1 && <1.1+ madlang >=1.0.1.0 && <1.1 default-language: Haskell2010 hs-source-dirs: app- ghc-options: -threaded -rtsopts -with-rtsopts=-N test-suite madlang-test type: exitcode-stdio-1.0 main-is: Spec.hs build-depends: base >=4.9.1.0 && <4.10,- madlang >=1.0.0.1 && <1.1,- hspec >=2.4.1 && <2.5,+ madlang >=1.0.1.0 && <1.1,+ hspec >=2.4.2 && <2.5, megaparsec >=5.2.0 && <5.3, text >=1.2.2.1 && <1.3, mtl >=2.2.1 && <2.3,
src/Text/Madlibs/Ana/Parse.hs view
@@ -92,14 +92,14 @@ definition ins = do define str <- name- val <- some $ pair ins+ val <- fmap normalize . some $ pair ins pure (T.pack str, val) -- | Parse the `:return` block final :: [T.Text] -> Parser [(Prob, [PreTok])] final ins = do main- val <- some $ pair ins+ val <- fmap normalize . some $ pair ins pure val -- | Parse the program in terms of `PreTok` and the `Key`s to link them.
src/Text/Madlibs/Internal/Utils.hs view
@@ -9,6 +9,7 @@ import Text.Megaparsec.Error import qualified Data.Text as T import System.IO.Unsafe+import Control.Lens -- | Function to apply a value on both arguments, e.g. --@@ -21,6 +22,10 @@ instance (Monoid a) => Monoid (Parser a) where mempty = pure mempty mappend x y = mappend <$> x <*> y++normalize :: [(Prob, [PreTok])] -> [(Prob, [PreTok])]+normalize list = map (over _1 (/total)) list+ where total = sum . map fst $ list -- | Helper function for creating a cdf from a pdf cdf :: [Prob] -> [Prob]
stack-8.yaml view
@@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml"-resolver: lts-8.2+resolver: lts-8.4 # User packages to be built. # Various formats can be used as shown in the example below.
stack-nightly.yaml view
@@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml"-resolver: nightly-2017-02-24+resolver: nightly-2017-03-01 # User packages to be built. # Various formats can be used as shown in the example below.
stack.yaml view
@@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml"-resolver: lts-8.2+resolver: lts-8.4 # User packages to be built. # Various formats can be used as shown in the example below.
test/Spec.hs view
@@ -14,7 +14,7 @@ main :: IO () main = hspec $ do describe "parseTok" $ do- parallel$ it "parses a .mad string" $ do+ parallel $ it "parses a .mad string" $ do parseTok [] madFile `shouldParse` (List [(1.0,List [(0.5,Value "heads"),(0.5,Value "tails")])]) parallel $ it "fails when quotes aren't closed" $ do parseTok [] `shouldFailOn` madFileFailure