agum 2.7 → 2.8
raw patch · 5 files changed
+45/−40 lines, 5 filesdep ~base
Dependency ranges changed: base
Files
- ChangeLog +7/−0
- agum.cabal +27/−27
- src/Algebra/AbelianGroup/IntLinEq.hs +2/−2
- src/Algebra/AbelianGroup/Main.hs +8/−10
- src/Algebra/AbelianGroup/UnificationMatching.hs +1/−1
ChangeLog view
@@ -1,3 +1,10 @@+2019-10-15 John D. Ramsdell <ramsdell@mitre.org>++ * agum.cabal (Version): Released as version 2.8++ * src/Algebra/AbelianGroup/Main.hs (AnsErr): Updated code to+ support the MonadFail proposal as implemented in base-4.13.0.0.+ 2018-01-06 John D. Ramsdell <ramsdell@mitre.org> * src/Algebra/AbelianGroup/Main.hs (readM): Adapted the code to
agum.cabal view
@@ -1,40 +1,40 @@-Name: agum-Version: 2.7-Maintainer: ramsdell@mitre.org-Cabal-Version: >= 1.6-License: GPL-License-File: license.txt-Synopsis: Unification and Matching in an Abelian Group+Name: agum+Version: 2.8+Maintainer: ramsdell@mitre.org+Cabal-Version: >= 1.6+License: GPL+License-File: license.txt+Synopsis: Unification and Matching in an Abelian Group Description: The unification problem is given the problem- statement t =? t\', find a most general- substitution s such that s(t) = s(t\') modulo- the axioms of an Abelian group. The matching- problem is to find a most general substitution- s such that s(t) = t\' modulo the axioms.- Substitition s is more general than s\' if- there is a substitition s\" such that s\' =- s\" o s.-Category: Algebra-Build-Type: Simple-Extra-Source-Files: readme.txt ChangeLog Makefile+ statement t =? t\', find a most general+ substitution s such that s(t) = s(t\') modulo+ the axioms of an Abelian group. The matching+ problem is to find a most general substitution+ s such that s(t) = t\' modulo the axioms.+ Substitition s is more general than s\' if+ there is a substitition s\" such that s\' =+ s\" o s.+Category: Algebra+Build-Type: Simple+Extra-Source-Files: readme.txt ChangeLog Makefile Library- Build-Depends: base >= 3 && < 5, containers >= 0.3- Exposed-Modules: Algebra.AbelianGroup.UnificationMatching+ Build-Depends: base >= 4.13 && < 5, containers >= 0.3+ Exposed-Modules: Algebra.AbelianGroup.UnificationMatching Algebra.AbelianGroup.IntLinEq- Hs-Source-Dirs: src+ Hs-Source-Dirs: src GHC-Options: -Wall -fno-warn-name-shadowing -fwarn-unused-imports Executable agum- Main-Is: Algebra/AbelianGroup/Main.hs- Build-Depends: base >= 3 && < 5, containers >= 0.3- Other-Modules: Algebra.AbelianGroup.UnificationMatching+ Main-Is: Algebra/AbelianGroup/Main.hs+ Build-Depends: base >= 4.13 && < 5, containers >= 0.3+ Other-Modules: Algebra.AbelianGroup.UnificationMatching Algebra.AbelianGroup.IntLinEq- Hs-Source-Dirs: src+ Hs-Source-Dirs: src GHC-Options: -Wall -fno-warn-name-shadowing -fwarn-unused-imports Source-Repository head- Type: git- Location: git://github.com/ramsdell/agum.git+ Type: git+ Location: git://github.com/ramsdell/agum.git
src/Algebra/AbelianGroup/IntLinEq.hs view
@@ -109,7 +109,7 @@ -- | Find integer solutions to a linear equation or fail when there -- are no solutions.-intLinEq :: Monad m => LinEq -> m Subst+intLinEq :: MonadFail m => LinEq -> m Subst intLinEq (coefficients, constants) = intLinEqLoop (length coefficients) (coefficients, constants) [] @@ -120,7 +120,7 @@ -- On input, n is the number of variables in the original problem, c -- is the coefficients, d is the constants, and subst is a list of -- eliminated variables.-intLinEqLoop :: Monad m => Int -> LinEq -> Subst -> m Subst+intLinEqLoop :: MonadFail m => Int -> LinEq -> Subst -> m Subst intLinEqLoop n (c, d) subst = -- Find the smallest non-zero coefficient in absolute value let (i, ci) = smallest c in
src/Algebra/AbelianGroup/Main.hs view
@@ -17,7 +17,6 @@ module Main (main, test) where -import qualified Control.Monad.Fail as Fail import System.IO (isEOF, hFlush, stdout) import Algebra.AbelianGroup.UnificationMatching @@ -41,12 +40,12 @@ Ans subst -> print subst putStrLn "" -readM :: (Read a, Fail.MonadFail m) => String -> m a+readM :: (Read a, MonadFail m) => String -> m a readM s = case [ x | (x, t) <- reads s, ("", "") <- lex t ] of [x] -> return x- [] -> Fail.fail "no parse"- _ -> Fail.fail "ambiguous parse"+ [] -> fail "no parse"+ _ -> fail "ambiguous parse" -- Like Either String but with fail method defined data AnsErr a@@ -58,17 +57,16 @@ fmap f (Ans y) = Ans (f y) instance Applicative (AnsErr) where- pure = Ans+ pure = Ans Err e <*> _ = Err e Ans f <*> r = fmap f r instance Monad AnsErr where- (Ans x) >>= k = k x- (Err s) >>= _ = Err s- return = Ans+ Ans x >>= k = k x+ Err s >>= _ = Err s -instance Fail.MonadFail AnsErr where- fail = Err -- fail is Err+instance MonadFail AnsErr where+ fail = Err -- fail is Err -- Main loop
src/Algebra/AbelianGroup/UnificationMatching.hs view
@@ -227,7 +227,7 @@ -- | Given 'Equation' (t0, t1), return a most general substitution s -- such that s(t0) = t1 modulo the equational axioms of an Abelian -- group.-match :: Monad m => Equation -> m Substitution+match :: MonadFail m => Equation -> m Substitution match (Equation (t0, t1)) = case (assocs t0, assocs t1) of ([], []) -> return $ Substitution Map.empty