madlang 1.0.1.0 → 1.1.1.0
raw patch · 8 files changed
+16/−143 lines, 8 filesdep ~madlang
Dependency ranges changed: madlang
Files
- madlang.cabal +3/−5
- src/Text/Madlibs/Ana/Parse.hs +3/−1
- src/Text/Madlibs/Ana/ParseUtils.hs +5/−3
- src/Text/Madlibs/Exec/Main.hs +3/−0
- src/Text/Madlibs/Internal/Types.hs +1/−1
- stack-8.yaml +0/−66
- stack-nightly.yaml +0/−66
- stack.yaml +1/−1
madlang.cabal view
@@ -1,5 +1,5 @@ name: madlang-version: 1.0.1.0+version: 1.1.1.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -18,8 +18,6 @@ test/templates/*.mad test/templates/err/*.mad stack.yaml- stack-8.yaml- stack-nightly.yaml source-repository head type: git@@ -65,7 +63,7 @@ main-is: Main.hs build-depends: base >=4.9.1.0 && <4.10,- madlang >=1.0.1.0 && <1.1+ madlang >=1.1.1.0 && <1.2 default-language: Haskell2010 hs-source-dirs: app @@ -74,7 +72,7 @@ main-is: Spec.hs build-depends: base >=4.9.1.0 && <4.10,- madlang >=1.0.1.0 && <1.1,+ madlang >=1.1.1.0 && <1.2, hspec >=2.4.2 && <2.5, megaparsec >=5.2.0 && <5.3, text >=1.2.2.1 && <1.3,
src/Text/Madlibs/Ana/Parse.hs view
@@ -13,6 +13,8 @@ import Data.Monoid import Control.Monad import Control.Monad.State+--+import System.IO.Unsafe -- | Parse a lexeme, aka deal with whitespace nicely. lexeme :: Parser a -> Parser a@@ -110,7 +112,7 @@ -- | Parse text as a token + context (aka a reader monad with all the other functions) parseTokM :: [T.Text] -> Parser (Context RandTok)-parseTokM ins = fmap build $ program ins+parseTokM ins = build <$> program ins -- | Parse text as a token --
src/Text/Madlibs/Ana/ParseUtils.hs view
@@ -9,6 +9,7 @@ import Control.Monad.State import Data.Foldable import Control.Exception+import Control.Arrow --consider moving Ana.ParseUtils to Cata.Sorting @@ -17,7 +18,7 @@ concatTok param pretoks = do ctx <- get let unList (List a) = a- let toRand (Name str) = List . snd . (head' str param) . (filter ((== str) . fst)). (map (\(i,j) -> (i, unList j))) $ ctx+ let toRand (Name str) = List . snd . (head' str param) . (filter ((== str) . fst)). (map (second unList)) $ ctx toRand (PreTok txt) = Value txt fold . (map toRand) <$> pretoks @@ -26,8 +27,8 @@ build list | length list == 1 = do let [(key, pairs)] = list- toks <- sequence $ map (\(i,j) -> concatTok key (pure j)) $ pairs- let probs = map (fst) $ pairs+ toks <- mapM (\(i,j) -> concatTok key (pure j)) pairs+ let probs = map fst pairs let tok = List $ zip probs toks state (\s -> (tok,((key, tok):s))) --should do: recurse or take "Template" key@@ -48,4 +49,5 @@ | key2 == "Template" = LT | any (\pair -> any (T.isInfixOf key1) (map unTok . snd $ pair)) l1 = LT | any (\pair -> any (T.isInfixOf key2) (map unTok . snd $ pair)) l1 = GT+ -- issue: if we define nationality, subject object NOW object can't be used in subject? | otherwise = EQ
src/Text/Madlibs/Exec/Main.hs view
@@ -62,8 +62,11 @@ parseFile :: [T.Text] -> FilePath -> IO (Either (ParseError Char Dec) RandTok) parseFile ins filepath = do txt <- readFile' filepath+ --print $ runParser (program ins) "" txt let val = parseTok ins txt pure val++-- pure . unsafePerformIO . print $ runParser (program ins) "" f -- | String with git commit string build :: String
src/Text/Madlibs/Internal/Types.hs view
@@ -33,7 +33,7 @@ mempty = Value "" mappend (Value v1) (Value v2) = Value (T.append v1 v2) mappend (List l1) v@(Value v1) = List $ map (over (_2) (`mappend` v)) l1 - mappend v@(Value v2) (List l2) = List $ map (over (_2) (`mappend` v)) l2+ mappend v@(Value v2) (List l2) = List $ map (over (_2) (v `mappend`)) l2 mappend l@(List l1) (List l2) = List [ (p, l `mappend` tok) | (p,tok) <- l2 ] -- | State monad providing context, i.e. function we've already called before
− stack-8.yaml
@@ -1,66 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# http://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-# resolver: ghcjs-0.1.0_ghc-7.10.2-# resolver:-# name: custom-snapshot-# location: "./custom-snapshot.yaml"-resolver: lts-8.4--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# extra-dep: true-# subdirs:-# - auto-update-# - wai-#-# A package marked 'extra-dep: true' will only be built if demanded by a-# non-dependency (i.e. a user package), and its test suites and benchmarks-# will not be run. This is useful for tweaking upstream packages.-packages:-- '.'-# Dependency packages to be pulled from upstream that are not in the resolver-# (e.g., acme-missiles-0.3)-extra-deps: []--# Override default flag values for local packages and extra-deps-flags: {}--# Extra package databases containing global packages-extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.4"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor
− stack-nightly.yaml
@@ -1,66 +0,0 @@-# This file was automatically generated by 'stack init'-#-# Some commonly used options have been documented as comments in this file.-# For advanced use and comprehensive documentation of the format, please see:-# http://docs.haskellstack.org/en/stable/yaml_configuration/--# Resolver to choose a 'specific' stackage snapshot or a compiler version.-# A snapshot resolver dictates the compiler version and the set of packages-# to be used for project dependencies. For example:-#-# resolver: lts-3.5-# resolver: nightly-2015-09-21-# resolver: ghc-7.10.2-# resolver: ghcjs-0.1.0_ghc-7.10.2-# resolver:-# name: custom-snapshot-# location: "./custom-snapshot.yaml"-resolver: nightly-2017-03-01--# User packages to be built.-# Various formats can be used as shown in the example below.-#-# packages:-# - some-directory-# - https://example.com/foo/bar/baz-0.0.2.tar.gz-# - location:-# git: https://github.com/commercialhaskell/stack.git-# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a-# extra-dep: true-# subdirs:-# - auto-update-# - wai-#-# A package marked 'extra-dep: true' will only be built if demanded by a-# non-dependency (i.e. a user package), and its test suites and benchmarks-# will not be run. This is useful for tweaking upstream packages.-packages:-- '.'-# Dependency packages to be pulled from upstream that are not in the resolver-# (e.g., acme-missiles-0.3)-extra-deps: []--# Override default flag values for local packages and extra-deps-flags: {}--# Extra package databases containing global packages-extra-package-dbs: []--# Control whether we use the GHC we find on the path-# system-ghc: true-#-# Require a specific version of stack, using version ranges-# require-stack-version: -any # Default-# require-stack-version: ">=1.4"-#-# Override the architecture used by stack, especially useful on Windows-# arch: i386-# arch: x86_64-#-# Extra directories used by stack for building-# extra-include-dirs: [/path/to/dir]-# extra-lib-dirs: [/path/to/dir]-#-# Allow a newer minor version of GHC than the snapshot specifies-# compiler-check: newer-minor
stack.yaml view
@@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml"-resolver: lts-8.4+resolver: lts-8.5 # User packages to be built. # Various formats can be used as shown in the example below.