ersatz 0.4.4 → 0.4.5
raw patch · 14 files changed
+171/−182 lines, 14 filesdep +faildep −hlintdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: fail
Dependencies removed: hlint
Dependency ranges changed: base
API changes (from Hackage documentation)
- Ersatz.Codec: instance Ersatz.Codec.Codec a => Ersatz.Codec.Codec (GHC.Base.Maybe a)
- Ersatz.Equatable: instance Ersatz.Equatable.Equatable a => Ersatz.Equatable.Equatable (GHC.Base.Maybe a)
- Ersatz.Orderable: instance Ersatz.Orderable.Orderable a => Ersatz.Orderable.Orderable (GHC.Base.Maybe a)
+ Ersatz.Bit: infixr 0 ==>
+ Ersatz.Bit: infixr 2 ||
+ Ersatz.Bit: infixr 3 &&
+ Ersatz.Codec: instance Ersatz.Codec.Codec a => Ersatz.Codec.Codec (GHC.Maybe.Maybe a)
+ Ersatz.Equatable: infix 4 /==
+ Ersatz.Equatable: instance Ersatz.Equatable.Equatable a => Ersatz.Equatable.Equatable (GHC.Maybe.Maybe a)
+ Ersatz.Orderable: infix 4 >?
+ Ersatz.Orderable: instance Ersatz.Orderable.Orderable a => Ersatz.Orderable.Orderable (GHC.Maybe.Maybe a)
- Ersatz.Bit: And :: !(Seq Bit) -> Bit
+ Ersatz.Bit: And :: !Seq Bit -> Bit
- Ersatz.Problem: SAT :: {-# UNPACK #-} !Int -> !Formula -> !(HashMap (StableName ()) Literal) -> SAT
+ Ersatz.Problem: SAT :: {-# UNPACK #-} !Int -> !Formula -> !HashMap (StableName ()) Literal -> SAT
- Ersatz.Relation: anti_symmetric :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: anti_symmetric :: Ix a => Relation a a -> Bit
- Ersatz.Relation: identity :: (Ix a) => ((a, a), (a, a)) -> Relation a a
+ Ersatz.Relation: identity :: Ix a => ((a, a), (a, a)) -> Relation a a
- Ersatz.Relation: irreflexive :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: irreflexive :: Ix a => Relation a a -> Bit
- Ersatz.Relation: power :: (Ix a) => Int -> Relation a a -> Relation a a
+ Ersatz.Relation: power :: Ix a => Int -> Relation a a -> Relation a a
- Ersatz.Relation: reflexive :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: reflexive :: Ix a => Relation a a -> Bit
- Ersatz.Relation: symmetric :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: symmetric :: Ix a => Relation a a -> Bit
- Ersatz.Relation: total :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: total :: Ix a => Relation a a -> Bit
- Ersatz.Relation: transitive :: (Ix a) => Relation a a -> Bit
+ Ersatz.Relation: transitive :: Ix a => Relation a a -> Bit
- Ersatz.Solution: Solution :: Literal -> Maybe Bool -> StableName () -> Maybe Bool -> Solution
+ Ersatz.Solution: Solution :: (Literal -> Maybe Bool) -> (StableName () -> Maybe Bool) -> Solution
Files
- .hlint.yaml +5/−0
- .travis.yml +135/−108
- CHANGELOG.md +4/−0
- ersatz.cabal +6/−23
- examples/regexp-grid/RegexpGrid/Problem.hs +6/−3
- src/Ersatz/Bit.hs +5/−8
- src/Ersatz/BitChar.hs +2/−2
- src/Ersatz/Equatable.hs +0/−3
- src/Ersatz/Internal/Formula.hs +0/−1
- src/Ersatz/Orderable.hs +2/−0
- src/Ersatz/Problem.hs +1/−3
- src/Ersatz/Relation/Data.hs +2/−2
- src/Ersatz/Variable.hs +3/−6
- tests/hlint.hs +0/−23
+ .hlint.yaml view
@@ -0,0 +1,5 @@+- ignore:+ name: Use camelCase++- ignore:+ name: Use lambda-case
.travis.yml view
@@ -1,150 +1,177 @@ # This Travis job script has been generated by a script via #-# runghc make_travis_yml_2.hs '-o' '.travis.yml' '--ghc-head' '--irc-channel=irc.freenode.org#haskell-lens' '--no-no-tests-no-bench' '--no-unconstrained' 'cabal.project'+# haskell-ci '--output=.travis.yml' '--config=cabal.haskell-ci' 'cabal.project' #-# For more information, see https://github.com/hvr/multi-ghc-travis+# For more information, see https://github.com/haskell-CI/haskell-ci #+# version: 0.3.20190425+# language: c-sudo: false-+dist: xenial git:- submodules: false # whether to recursively clone submodules-+ # whether to recursively clone submodules+ submodules: false notifications: irc: channels:- - "irc.freenode.org#haskell-lens"+ - irc.freenode.org#haskell-lens skip_join: true template:- - "\x0313ersatz\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"-+ - "\"\\x0313ersatz\\x03/\\x0306%{branch}\\x03 \\x0314%{commit}\\x03 %{build_url} %{message}\"" cache: directories: - $HOME/.cabal/packages - $HOME/.cabal/store- before_cache:- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log+ - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log # remove files that are regenerated by 'cabal update'- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx-- - rm -rfv $HOME/.cabal/packages/head.hackage--addons:- apt:- packages: &apt_packages- - ghc-ppa-tools- - minisat- - alex-3.1.7- - happy-1.19.5-+ - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*+ - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx+ - rm -rfv $CABALHOME/packages/head.hackage matrix: include:- - compiler: "ghc-8.6.1"+ - compiler: ghc-8.8.1+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0","minisat"]}} env: GHCHEAD=true- addons: {apt: {packages: [*apt_packages,cabal-install-head,ghc-8.6.1], sources: [hvr-ghc]}}- - compiler: "ghc-8.4.3"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}- - compiler: "ghc-8.2.2"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}- - compiler: "ghc-8.0.2"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}}- - compiler: "ghc-7.10.3"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.2,ghc-7.10.3], sources: [hvr-ghc]}}- - compiler: "ghc-head"+ - compiler: ghc-8.6.5+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4","minisat"]}}+ - compiler: ghc-8.4.4+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4","minisat"]}}+ - compiler: ghc-8.2.2+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4","minisat"]}}+ - compiler: ghc-8.0.2+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4","minisat"]}}+ - compiler: ghc-7.10.3+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4","minisat"]}}+ - compiler: ghc-head+ addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head","minisat"]}} env: GHCHEAD=true- addons: {apt: {packages: [*apt_packages,cabal-install-head,ghc-head], sources: [hvr-ghc]}}- allow_failures:- - compiler: "ghc-head"- - compiler: "ghc-8.6.1"-+ - compiler: ghc-head+ - compiler: ghc-8.8.1 before_install:- - HC=${CC}- - HCPKG=${HC/ghc/ghc-pkg}+ - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')+ - HCPKG="$HC-pkg" - unset CC- - ROOTDIR=$(pwd)- - mkdir -p $HOME/.local/bin- - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"+ - CABAL=/opt/ghc/bin/cabal+ - CABALHOME=$HOME/.cabal+ - export PATH="$CABALHOME/bin:$PATH"+ - TOP=$(pwd) - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') )) - echo $HCNUMVER-+ - CABAL="$CABAL -vnormal+nowrap+markoutput"+ - set -o pipefail+ - |+ echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk+ echo 'BEGIN { state = "output"; }' >> .colorful.awk+ echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk+ echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk+ echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk+ echo ' if (state == "cabal") {' >> .colorful.awk+ echo ' print blue($0)' >> .colorful.awk+ echo ' } else {' >> .colorful.awk+ echo ' print $0' >> .colorful.awk+ echo ' }' >> .colorful.awk+ echo '}' >> .colorful.awk+ - cat .colorful.awk+ - |+ color_cabal_output () {+ awk -f $TOP/.colorful.awk+ }+ - echo text | color_cabal_output install:- - cabal --version+ - ${CABAL} --version - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"- - BENCH=${BENCH---enable-benchmarks}- - TEST=${TEST---enable-tests}- - HADDOCK=${HADDOCK-true}- - UNCONSTRAINED=${UNCONSTRAINED-true}- - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}+ - TEST=--enable-tests+ - BENCH=--enable-benchmarks - GHCHEAD=${GHCHEAD-false}- - travis_retry cabal update -v- - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"- - rm -fv cabal.project cabal.project.local- # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage+ - rm -f $CABALHOME/config - |+ echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config+ echo "remote-build-reporting: anonymous" >> $CABALHOME/config+ echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config+ echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config+ echo "world-file: $CABALHOME/world" >> $CABALHOME/config+ echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config+ echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config+ echo "installdir: $CABALHOME/bin" >> $CABALHOME/config+ echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config+ echo "store-dir: $CABALHOME/store" >> $CABALHOME/config+ echo "install-dirs user" >> $CABALHOME/config+ echo " prefix: $CABALHOME" >> $CABALHOME/config+ echo "repository hackage.haskell.org" >> $CABALHOME/config+ echo " url: http://hackage.haskell.org/" >> $CABALHOME/config+ - | if $GHCHEAD; then- sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config- for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done-- echo 'repository head.hackage' >> ${HOME}/.cabal/config- echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config- echo ' secure: True' >> ${HOME}/.cabal/config- echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config- echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config- echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config- echo ' key-threshold: 3' >> ${HOME}/.cabal.config-- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'-- cabal new-update head.hackage -v+ echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config+ + echo "repository head.hackage" >> $CABALHOME/config+ echo " url: http://head.hackage.haskell.org/" >> $CABALHOME/config+ echo " secure: True" >> $CABALHOME/config+ echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config+ echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config+ echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config+ echo " key-threshold: 3" >> $CABALHOME/config fi- - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'- - "printf 'packages: \".\"\\n' > cabal.project"- - touch cabal.project.local- - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"+ - cat $CABALHOME/config+ - rm -fv cabal.project cabal.project.local cabal.project.freeze+ - travis_retry ${CABAL} v2-update -v+ - if [ $HCNUMVER -eq 80801 ] ; then ${CABAL} v2-install -w ${HC} -j2 hlint --constraint='hlint ==2.1.*' | color_cabal_output ; fi+ # Generate cabal.project+ - rm -rf cabal.project cabal.project.local cabal.project.freeze+ - touch cabal.project+ - |+ echo 'packages: "."' >> cabal.project+ - |+ echo "package ersatz" >> cabal.project+ echo " flags: +examples" >> cabal.project+ echo "" >> cabal.project+ echo "write-ghc-environment-files: always" >> cabal.project+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(ersatz)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true- - if [ -f "./configure.ac" ]; then- (cd "." && autoreconf -i);- fi- - rm -f cabal.project.freeze- - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all- - rm -rf .ghc.environment.* "."/dist- - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)--# Here starts the actual work to be performed for the package under test;-# any command which exits with a non-zero exit code causes the build to fail.+ - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi+ - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output+ - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"+ - rm cabal.project.freeze+ - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output script:- # test that source-distributions can be generated- - (cd "." && cabal sdist)- - mv "."/dist/ersatz-*.tar.gz ${DISTDIR}/+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)+ # Packaging...+ - ${CABAL} v2-sdist all | color_cabal_output+ # Unpacking...+ - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ - cd ${DISTDIR} || false - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;- - "printf 'packages: ersatz-*/*.cabal\\n' > cabal.project"- - touch cabal.project.local- - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"+ # Generate cabal.project+ - rm -rf cabal.project cabal.project.local cabal.project.freeze+ - touch cabal.project+ - |+ echo 'packages: "ersatz-*/*.cabal"' >> cabal.project+ - |+ echo "package ersatz" >> cabal.project+ echo " flags: +examples" >> cabal.project+ echo "" >> cabal.project+ echo "write-ghc-environment-files: always" >> cabal.project+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(ersatz)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done" - cat cabal.project || true - cat cabal.project.local || true-+ # Building with tests and benchmarks... # build & run tests, build benchmarks- - cabal new-build -w ${HC} ${TEST} ${BENCH} all- - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi-- # cabal check- - (cd ersatz-* && cabal check)-- # haddock- - rm -rf ./dist-newstyle- - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi+ - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ # Testing...+ - ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+ # HLint..+ - if [ $HCNUMVER -eq 80801 ] ; then (cd ersatz-* && hlint --cpp-ansi --cpp-define=HLINT src) ; fi+ - if [ $HCNUMVER -eq 80801 ] ; then (cd ersatz-* && hlint --cpp-ansi --cpp-define=HLINT examples/sudoku) ; fi+ - if [ $HCNUMVER -eq 80801 ] ; then (cd ersatz-* && hlint --cpp-ansi --cpp-define=HLINT examples/regexp-grid) ; fi+ # cabal check...+ - (cd ersatz-* && ${CABAL} -vnormal check)+ # haddock...+ - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output -# REGENDATA ["-o",".travis.yml","--ghc-head","--irc-channel=irc.freenode.org#haskell-lens","--no-no-tests-no-bench","--no-unconstrained","cabal.project"]+# REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"] # EOF
CHANGELOG.md view
@@ -1,3 +1,7 @@+0.4.5 [2019.05.02]+------------------+* Allow `ersatz-regexp-grid` to build with `base-4.13` (GHC 8.8).+ 0.4.4 [2018.08.13] ------------------ * Avoid the use of failable pattern matches in `do`-notation to support
ersatz.cabal view
@@ -1,5 +1,5 @@ name: ersatz-version: 0.4.4+version: 0.4.5 license: BSD3 license-file: LICENSE author: Edward A. Kmett, Eric Mertens, Johan Kiviniemi@@ -78,11 +78,13 @@ tested-with: GHC == 7.10.3 , GHC == 8.0.2 , GHC == 8.2.2- , GHC == 8.4.3- , GHC == 8.6.1+ , GHC == 8.4.4+ , GHC == 8.6.5+ , GHC == 8.8.1 extra-source-files: .ghci .gitignore+ .hlint.yaml .travis.yml AUTHORS.md CHANGELOG.md@@ -167,12 +169,6 @@ default: True manual: True --- You can enable the hlint test suite with -ftest-hlint-flag test-hlint- default: False- manual: True-- library ghc-options: -Wall hs-source-dirs: src@@ -230,6 +226,7 @@ base < 5, containers, ersatz,+ fail, lens, mtl, parsec >= 3.1 && < 3.2,@@ -300,20 +297,6 @@ filepath ghc-options: -Wall -threaded hs-source-dirs: tests--test-suite hlint- type: exitcode-stdio-1.0- main-is: hlint.hs- ghc-options: -w -threaded -rtsopts -with-rtsopts=-N- hs-source-dirs: tests- default-language: Haskell2010-- if !flag(test-hlint)- buildable: False- else- build-depends:- base,- hlint >= 1.7 test-suite speed type: exitcode-stdio-1.0
examples/regexp-grid/RegexpGrid/Problem.hs view
@@ -9,6 +9,7 @@ import Prelude hiding ((&&), (||), not, and, or, all, any) import Control.Applicative+import qualified Control.Monad.Fail as Fail import Control.Monad.Reader import Control.Monad.RWS.Strict hiding ((<>)) import Control.Lens@@ -58,14 +59,16 @@ {-# INLINE mappend #-} #endif -problem :: (Applicative m, MonadState s m, HasSAT s) => m (Map Pos Field)+problem :: (Applicative m, Fail.MonadFail m, MonadState s m, HasSAT s)+ => m (Map Pos Field) problem = do -- Allocate a literal for each field. fieldMap <- Map.fromList <$> mapM (\pos -> (pos,) <$> exists) [minBound..] runReaderT problem' fieldMap return fieldMap -problem' :: (MonadState s m, HasSAT s) => ReaderT (Map Pos Field) m ()+problem' :: (Fail.MonadFail m, MonadState s m, HasSAT s)+ => ReaderT (Map Pos Field) m () problem' = do r [P00,P01,P02,P03,P04,P05,P06] ".*H.*H.*" r [P10,P11,P12,P13,P14,P15,P16,P17] "(DI|NS|TH|OM)*"@@ -109,7 +112,7 @@ r [P7b,P6b,P5a,P49,P38,P27,P16,P05] "[^M]*M[^M]*" r [P6c,P5b,P4a,P39,P28,P17,P06] "(S|MM|HHH)*" -r :: (MonadState s m, HasSAT s)+r :: (Fail.MonadFail m, MonadState s m, HasSAT s) => [Pos] -> String -> ReaderT (Map Pos Field) m () r poss regexpStr = do fieldMap <- ask
src/Ersatz/Bit.hs view
@@ -8,7 +8,6 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE Rank2Types #-}-{-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_HADDOCK not-home #-} -------------------------------------------------------------------- -- |@@ -103,14 +102,14 @@ a `xor` b = Xor a b and = Foldable.foldl' (&&) true- or = not . and . map not . toList+ or = not . all not . toList all p = Foldable.foldl' (\res b -> res && p b) true any p = not . all (not . p) choose f _ (Var (Literal (-1))) = f choose _ t (Var (Literal 1)) = t- choose t f (Not s) = choose f t s + choose t f (Not s) = choose f t s choose f t s = Mux f t s and2 :: Bit -> Bit -> Bit@@ -124,7 +123,7 @@ and2 a b = And (a <| b <| Seq.empty) instance Variable Bit where- literally = liftM Var . literally+ literally = fmap Var . literally -- a Bit you don't assert is actually a boolean function that you can evaluate later after compilation instance Codec Bit where@@ -173,12 +172,12 @@ -- | Convert a 'Bit' to a 'Literal'. runBit :: (MonadState s m, HasSAT s) => Bit -> m Literal-runBit (Not c) = negateLiteral `liftM` runBit c+runBit (Not c) = negateLiteral `fmap` runBit c runBit (Var l) = return l runBit (Run action) = action >>= runBit runBit b = generateLiteral b $ \out -> assertFormula =<< case b of- And bs -> formulaAnd out `liftM` mapM runBit (toList bs)+ And bs -> formulaAnd out `fmap` mapM runBit (toList bs) Xor x y -> liftM2 (formulaXor out) (runBit x) (runBit y) Mux x y p -> liftM3 (formulaMux out) (runBit x) (runBit y) (runBit p) @@ -309,7 +308,6 @@ -> b choose f t s = (f && not s) || (t && s) -#ifndef HLINT default bool :: (Generic b, GBoolean (Rep b)) => Bool -> b bool = to . gbool @@ -330,7 +328,6 @@ default xor :: (Generic b, GBoolean (Rep b)) => b -> b -> b xor x y = to (from x `gxor` from y)-#endif instance Boolean Bool where bool = id
src/Ersatz/BitChar.hs view
@@ -12,7 +12,7 @@ module Ersatz.BitChar where import Data.Char (chr,ord)-import Control.Monad (liftM, replicateM)+import Control.Monad (replicateM) import Prelude hiding ((&&)) import Data.Typeable (Typeable) @@ -33,7 +33,7 @@ instance Codec BitChar where type Decoded BitChar = Char encode = BitChar . fromIntegral . ord- decode s (BitChar xs) = liftM (chr . fromIntegral) (decode s xs)+ decode s (BitChar xs) = fmap (chr . fromIntegral) (decode s xs) instance Equatable BitChar where BitChar xs === BitChar ys = xs === ys
src/Ersatz/Equatable.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-}@@ -36,10 +35,8 @@ class Equatable t where -- | Compare for equality within the SAT problem. (===) :: t -> t -> Bit-#ifndef HLINT default (===) :: (Generic t, GEquatable (Rep t)) => t -> t -> Bit a === b = from a ===# from b-#endif -- | Compare for inequality within the SAT problem. (/==) :: t -> t -> Bit
src/Ersatz/Internal/Formula.hs view
@@ -2,7 +2,6 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE MultiParamTypeClasses #-}
src/Ersatz/Orderable.hs view
@@ -2,7 +2,9 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-}+#ifndef HLINT {-# LANGUAGE DefaultSignatures #-}+#endif {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-}
src/Ersatz/Problem.hs view
@@ -3,7 +3,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE TypeOperators #-}-{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-}@@ -46,7 +45,6 @@ import Data.ByteString.Builder import Control.Lens-import Control.Monad import Control.Monad.State import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as Lazy@@ -131,7 +129,7 @@ dimacsSAT = toLazyByteString . dimacs . snd . runSAT' literalExists :: (MonadState s m, HasSAT s) => m Literal-literalExists = liftM Literal $ lastAtom <+= 1+literalExists = fmap Literal $ lastAtom <+= 1 {-# INLINE literalExists #-} assertFormula :: (MonadState s m, HasSAT s) => Formula -> m ()
src/Ersatz/Relation/Data.hs view
@@ -44,8 +44,8 @@ guard $ p <= q return $ do x <- exists- return $ [ ((p,q), x ) ]- ++ [ ((q,p), x) | p /= q ]+ return $ ((p,q), x)+ : [ ((q,p), x) | p /= q ] return $ build bnd $ concat pairs build :: ( Ix a, Ix b )
src/Ersatz/Variable.hs view
@@ -47,27 +47,24 @@ gliterally m = liftM2 (:*:) (gliterally m) (gliterally m) instance Variable a => GVariable (K1 i a) where- gliterally = liftM K1 . literally+ gliterally = fmap K1 . literally instance GVariable f => GVariable (M1 i c f) where- gliterally = liftM M1 . gliterally+ gliterally = fmap M1 . gliterally -- | Instances for this class for product-like types can be automatically derived -- for any type that is an instance of 'Generic'. class Variable t where literally :: (HasSAT s, MonadState s m) => m Literal -> m t--#ifndef HLINT default literally :: (HasSAT s, MonadState s m, Generic t, GVariable (Rep t)) => m Literal -> m t literally = genericLiterally-#endif genericLiterally :: (HasSAT s, MonadState s m, Generic t, GVariable (Rep t)) => m Literal -> m t-genericLiterally = liftM to . gliterally+genericLiterally = fmap to . gliterally instance Variable Literal where literally = id
− tests/hlint.hs
@@ -1,23 +0,0 @@--------------------------------------------------------------------------------- |--- Module : Main (hlint)--- Copyright : (C) 2013-2014 Edward Kmett--- License : BSD-style (see the file LICENSE)--- Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ This module runs HLint on the lens source tree.-------------------------------------------------------------------------------module Main where--import Control.Monad-import Language.Haskell.HLint-import System.Environment-import System.Exit--main :: IO ()-main = do- args <- getArgs- hints <- hlint $ ["src", "--cpp-define=HLINT", "--cpp-ansi"] ++ args- unless (null hints) exitFailure