summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmariNorman <>2013-08-30 15:37:28 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2013-08-30 15:37:28 (GMT)
commitb67cc94075608a507ece9ef4146b00aa5c3f4d55 (patch)
tree96fa4df6ff9ea27520fdac291e42ecbd036282eb
parent6c79142079bc50d65376ea6f306bb06d991233fa (diff)
version 0.28.0.00.28.0.0
-rw-r--r--bin/penny-selloff.hs43
-rw-r--r--doc/man/penny.15
-rw-r--r--lib/Penny/Brenner.hs23
-rw-r--r--lib/Penny/Brenner/Clear.hs5
-rw-r--r--lib/Penny/Brenner/Import.hs7
-rw-r--r--lib/Penny/Brenner/Info.hs3
-rw-r--r--lib/Penny/Brenner/OFX.hs39
-rw-r--r--lib/Penny/Brenner/Print.hs7
-rw-r--r--lib/Penny/Brenner/Types.hs5
-rw-r--r--lib/Penny/Brenner/Util.hs15
-rw-r--r--lib/Penny/Cabin/Balance/Convert.hs13
-rw-r--r--lib/Penny/Cabin/Balance/Convert/Parser.hs7
-rw-r--r--lib/Penny/Cabin/Interface.hs7
-rw-r--r--lib/Penny/Cabin/Posts.hs11
-rw-r--r--lib/Penny/Cabin/Posts/Parser.hs41
-rw-r--r--lib/Penny/Cabin/Scheme.hs2
-rw-r--r--lib/Penny/Copper/Parsec.hs13
-rw-r--r--lib/Penny/Liberty.hs142
-rw-r--r--lib/Penny/Lincoln/Bits/Qty.hs11
-rw-r--r--lib/Penny/Lincoln/Matchers.hs3
-rw-r--r--lib/Penny/Lincoln/PriceDb.hs11
-rw-r--r--lib/Penny/Lincoln/Serial.hs6
-rw-r--r--lib/Penny/Steel/Sums.hs11
-rw-r--r--lib/Penny/Wheat.hs11
-rw-r--r--lib/Penny/Zinc.hs43
-rw-r--r--penny.cabal30
-rw-r--r--tests/penny-gibberish.hs9
-rw-r--r--tests/penny-test.hs3
28 files changed, 248 insertions, 278 deletions
diff --git a/bin/penny-selloff.hs b/bin/penny-selloff.hs
index 92cfd7e..c377905 100644
--- a/bin/penny-selloff.hs
+++ b/bin/penny-selloff.hs
@@ -95,8 +95,8 @@ module Main (main) where
import Control.Arrow (first)
import Control.Applicative ((<$>), (<*>), pure)
-import qualified Control.Monad.Exception.Synchronous as Ex
import Control.Monad (when)
+import qualified Control.Monad.Trans.Either as Ei
import qualified Control.Monad.Trans.State as St
import Control.Monad.Trans.Class (lift)
import Data.List (find)
@@ -119,7 +119,7 @@ import qualified Text.Parsec as Parsec
import qualified Paths_penny as PPB
import qualified Penny as P
-type Err = Ex.Exceptional Error
+type Err = Either Error
data Error
= ParseFail MA.Error
@@ -153,8 +153,7 @@ parseCommandLine = do
x:xs <- case as of
[] -> fail (show NoInputArgs)
r -> return r
- a <- Ex.switch (fail . show . ProceedsParseFailed) return
- . Ex.fromEither
+ a <- either (fail . show . ProceedsParseFailed) return
$ Parsec.parse CP.lvl1Acct "" (pack x)
l <- Cop.open xs
return $ ParseResult (ProceedsAcct a) l
@@ -202,16 +201,15 @@ selloffInfo
:: ProceedsAcct -> [(L.Account, L.Balance)] -> Err SelloffInfo
selloffInfo (ProceedsAcct pa) bals = do
bal <- fmap snd
- . Ex.fromMaybe NoSelloffAccount
+ . maybe (Left NoSelloffAccount) Right
. find ((== pa) . fst)
$ bals
(g, d) <- case L.unAccount pa of
_ : s2 : s3 : [] -> return (s2, s3)
- _ -> Ex.throw NotThreeSelloffSubAccounts
+ _ -> Left NotThreeSelloffSubAccounts
(sStock, sCurr) <- selloffStockCurr bal
date <- fmap SaleDate
- . Ex.mapException SaleDateParseFailed
- . Ex.fromEither
+ . either (Left . SaleDateParseFailed) Right
. Parsec.parse CP.dateTime ""
$ (L.text d)
return $ SelloffInfo (Group g) date sStock sCurr
@@ -219,12 +217,12 @@ selloffInfo (ProceedsAcct pa) bals = do
selloffStockCurr :: L.Balance -> Err (SelloffStock, SelloffCurrency)
selloffStockCurr bal = do
let m = L.unBalance bal
- when (M.size m /= 2) $ Ex.throw BadSelloffBalance
+ when (M.size m /= 2) $ Left BadSelloffBalance
let toPair (cy, bl) = case bl of
Bal.Zero -> Nothing
Bal.NonZero col -> Just (cy, col)
ps = mapMaybe toPair . M.toList $ m
- findBal dc = Ex.fromMaybe BadSelloffBalance
+ findBal dc = maybe (Left BadSelloffBalance) Right
. find ((== dc) . Bal.colDrCr . snd)
$ ps
(cyStock, (Bal.Column _ qtyStock)) <- findBal L.Debit
@@ -276,9 +274,8 @@ purchaseInfo
purchaseInfo sStock sCurr (ss, bal) = do
dateSub <- case ss of
s1:[] -> return s1
- _ -> Ex.throw $ NotThreePurchaseSubAccounts ss
- date <- Ex.mapException BadPurchaseDate
- . Ex.fromEither
+ _ -> Left $ NotThreePurchaseSubAccounts ss
+ date <- either (Left . BadPurchaseDate) Right
. Parsec.parse CP.dateTime ""
. L.text
$ dateSub
@@ -292,18 +289,18 @@ purchaseQtys
-> Err (PurchaseStockQty, PurchaseCurrencyQty)
purchaseQtys (SelloffStock sStock) (SelloffCurrency sCurr) bal = do
let m = L.unBalance bal
- when (M.size m /= 2) $ Ex.throw BadPurchaseBalance
+ when (M.size m /= 2) $ Left BadPurchaseBalance
let toPair (cy, bl) = case bl of
Bal.Zero -> Nothing
Bal.NonZero col -> Just (cy, col)
ps = mapMaybe toPair . M.toList $ m
- findBal dc = Ex.fromMaybe BadPurchaseBalance
+ findBal dc = maybe (Left BadPurchaseBalance) Right
. find ((== dc) . Bal.colDrCr . snd)
$ ps
(cyStock, (Bal.Column _ qtyStock)) <- findBal L.Credit
(cyCurr, (Bal.Column _ qtyCurr)) <- findBal L.Debit
- when (cyStock /= L.commodity sStock) $ Ex.throw BadPurchaseBalance
- when (cyCurr /= L.commodity sCurr) $ Ex.throw BadPurchaseBalance
+ when (cyStock /= L.commodity sStock) $ Left BadPurchaseBalance
+ when (cyCurr /= L.commodity sCurr) $ Left BadPurchaseBalance
return (PurchaseStockQty qtyStock, PurchaseCurrencyQty qtyCurr)
@@ -332,7 +329,7 @@ data BasisRealiztn = BasisRealiztn
-- basis cannot be allocated.
stRealizeBasis
:: PurchaseInfo
- -> Ex.ExceptionalT Error
+ -> Ei.EitherT Error
(St.State (Maybe CostSharesSold, Maybe StillToRealize))
(Maybe (PurchaseInfo, BasisRealiztn))
stRealizeBasis p = do
@@ -387,11 +384,11 @@ realizeBases sellStck ps = do
let stReal = Just . StillToRealize . L.qty
. unSelloffStock $ sellStck
(exRs, (mayCss, mayTr)) = St.runState
- (Ex.runExceptionalT (mapM stRealizeBasis ps))
+ (Ei.runEitherT (mapM stRealizeBasis ps))
(Nothing, stReal)
rs <- exRs
- when (isJust mayTr) $ Ex.throw InsufficientSharePurchases
- css <- Ex.fromMaybe ZeroCostSharesSold mayCss
+ when (isJust mayTr) $ Left InsufficientSharePurchases
+ css <- maybe (Left ZeroCostSharesSold) Right mayCss
return (catMaybes rs, css)
newtype CapitalChange = CapitalChange { unCapitalChange :: L.Qty }
@@ -421,7 +418,7 @@ capitalChange css sc ls =
in case mayGainLoss of
Nothing -> return . NoChange $ ls
Just (qt, gl) -> do
- nePurchs <- Ex.fromMaybe NoPurchaseInformation
+ nePurchs <- maybe (Left NoPurchaseInformation) Right
. uncons $ ls
let qtys = mapNE (unPurchaseCurrencyQty . piCurrencyQty . fst)
nePurchs
@@ -615,7 +612,7 @@ main = parseCommandLine >>= handleParseResult
handleParseResult :: ParseResult -> IO ()
handleParseResult (ParseResult pa ldgr) =
- Ex.switch (error . show) TIO.putStr . makeOutput pa $ ldgr
+ either (error . show) TIO.putStr . makeOutput pa $ ldgr
defaultRadGroup :: S.S3 L.Radix L.PeriodGrp L.CommaGrp
defaultRadGroup = S.S3a L.Period
diff --git a/doc/man/penny.1 b/doc/man/penny.1
index c6d2b9a..1fdd6ac 100644
--- a/doc/man/penny.1
+++ b/doc/man/penny.1
@@ -458,11 +458,6 @@ Use the "pcre" matcher, which uses Perl-compatible regular expressions (see
.BR pcresyntax "(3) and " pcrepattern (3))
.TP
-.B --posix
-Use the "posix" matcher, which uses POSIX regular expressions (see
-.BR regex (7))
-
-.TP
.B "--exact | -x"
Use the "exact" matcher, which matches if the given pattern is a
letter-for-letter match of the target text, with case sensitivity
diff --git a/lib/Penny/Brenner.hs b/lib/Penny/Brenner.hs
index 0dc61fe..f0ef940 100644
--- a/lib/Penny/Brenner.hs
+++ b/lib/Penny/Brenner.hs
@@ -18,6 +18,7 @@ module Penny.Brenner
, usePayeeOrDesc
, brennerMain
, ofxParser
+ , ofxPrepassParser
) where
import qualified Penny.Brenner.Types as Y
@@ -37,7 +38,6 @@ import qualified Penny.Steel.Sums as Su
import qualified System.Console.MultiArg as MA
import System.Environment (getProgName)
import qualified System.Exit as Exit
-import qualified Control.Monad.Exception.Synchronous as Ex
-- | Brenner, with a pre-compiled configuration.
brennerMain
@@ -69,7 +69,7 @@ globalOpts v = MA.optsHelpVersion help (Ly.version v)
preProcessor
:: Y.Config
-> [Y.FitAcctName]
- -> Ex.Exceptional String
+ -> Either String
(Either (IO ())
[MA.Mode (MA.ProgName -> String) (IO ())])
preProcessor cf args = do
@@ -82,11 +82,11 @@ preProcessor cf args = do
Nothing -> Y.moreFitAccts cf
Just d -> d : Y.moreFitAccts cf
in case filter pdct toFilter of
- [] -> Ex.throw $
+ [] -> Left $
"financial institution account "
++ (X.unpack . Y.unFitAcctName $ s) ++ " not configured."
c:[] -> return $ Just c
- _ -> Ex.throw $
+ _ -> Left $
"more than one financial institution account "
++ "named " ++ (X.unpack . Y.unFitAcctName $ s)
++ " configured."
@@ -187,7 +187,7 @@ data FitAcct = FitAcct
-- commodity and the quantity
, parser :: ( Y.ParserDesc
- , Y.FitFileLocation -> IO (Ex.Exceptional String [Y.Posting]))
+ , Y.FitFileLocation -> IO (Either String [Y.Posting]))
-- ^ Parses a file of transactions from the financial
-- institution. The function must open the file and parse it. This
-- is in the IO monad not only because the function must open the
@@ -214,7 +214,7 @@ data FitAcct = FitAcct
-- created by the merge command.
- } deriving Show
+ }
convertFitAcct :: FitAcct -> Y.FitAcct
convertFitAcct (FitAcct fn fd db ax df cy gs tl sd sb ps tlp) = Y.FitAcct
@@ -235,7 +235,7 @@ convertFitAcct (FitAcct fn fd db ax df cy gs tl sd sb ps tlp) = Y.FitAcct
data Config = Config
{ defaultFitAcct :: Maybe FitAcct
, moreFitAccts :: [FitAcct]
- } deriving Show
+ }
convertConfig :: Config -> Y.Config
convertConfig (Config d m) = Y.Config
@@ -253,3 +253,12 @@ usePayeeOrDesc (Y.Desc d) (Y.Payee p) = L.Payee $
-- | Parser for OFX data.
ofxParser :: (Y.ParserDesc, Y.ParserFn)
ofxParser = O.parser
+
+-- | Parser for OFX data, with a prepass phase. Any incoming data is
+-- first filtered through the given function. This allows you to
+-- correct broken OFX statements. For example, Bank of America issues
+-- OFX files that do not properly escape ampersands. Using this
+-- function you can change every ampersand to something properly
+-- escaped (or just change it to the word \"and\".)
+ofxPrepassParser :: (String -> String) -> (Y.ParserDesc, Y.ParserFn)
+ofxPrepassParser = O.prepassParser
diff --git a/lib/Penny/Brenner/Clear.hs b/lib/Penny/Brenner/Clear.hs
index dce4acf..aa1686f 100644
--- a/lib/Penny/Brenner/Clear.hs
+++ b/lib/Penny/Brenner/Clear.hs
@@ -1,7 +1,6 @@
module Penny.Brenner.Clear (mode) where
import Control.Applicative
-import qualified Control.Monad.Exception.Synchronous as Ex
import Control.Monad (guard, mzero, when)
import Data.Maybe (mapMaybe, fromMaybe)
import Data.Monoid (mconcat, First(..))
@@ -57,7 +56,7 @@ data Opts = Opts
{ csvLocation :: Y.FitFileLocation
, ledgerLocations :: [String]
, printer :: X.Text -> IO ()
- } deriving Show
+ }
mode :: Y.Mode
@@ -84,7 +83,7 @@ runClear c os = do
dbList <- U.loadDb (Y.AllowNew False) (Y.dbLocation c)
let db = M.fromList dbList
(_, prsr) = Y.parser c
- txns <- fmap (Ex.switch fail return) $ prsr (csvLocation os)
+ txns <- fmap (either fail return) $ prsr (csvLocation os)
leds <- C.open (ledgerLocations os)
toClear <- case mapM (findUNumber db) (concat txns) of
Nothing -> fail $ "at least one posting was not found in the"
diff --git a/lib/Penny/Brenner/Import.hs b/lib/Penny/Brenner/Import.hs
index 5d78615..f4c76f5 100644
--- a/lib/Penny/Brenner/Import.hs
+++ b/lib/Penny/Brenner/Import.hs
@@ -1,7 +1,6 @@
module Penny.Brenner.Import (mode) where
import Control.Applicative ((<|>))
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Maybe (mapMaybe)
import qualified System.Console.MultiArg as MA
import qualified Penny.Brenner.Types as Y
@@ -28,7 +27,7 @@ data ImportOpts = ImportOpts
{ fitFile :: Y.FitFileLocation
, allowNew :: Y.AllowNew
, parser :: Y.FitFileLocation
- -> IO (Ex.Exceptional String [Y.Posting])
+ -> IO (Either String [Y.Posting])
, newUNumber :: Maybe Integer
}
@@ -111,8 +110,8 @@ doImport dbLoc os = do
txnsOld <- U.loadDb (allowNew os) dbLoc
parseResult <- parser os (fitFile os)
ins <- case parseResult of
- Ex.Exception e -> fail e
- Ex.Success g -> return g
+ Left e -> fail e
+ Right g -> return g
(new, len) <- case appendNew (newUNumber os) txnsOld ins of
Just r -> return r
Nothing -> fail "invalid new U number given."
diff --git a/lib/Penny/Brenner/Info.hs b/lib/Penny/Brenner/Info.hs
index d851213..6300107 100644
--- a/lib/Penny/Brenner/Info.hs
+++ b/lib/Penny/Brenner/Info.hs
@@ -1,7 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
module Penny.Brenner.Info (mode) where
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Penny.Brenner.Types as Y
import qualified Data.Text as X
import qualified Data.Text.IO as TIO
@@ -29,7 +28,7 @@ mode cf = MA.modeHelp
MA.Intersperse -- Interspersion
processPa -- Posarg processor
where
- processPa = const . Ex.throw . MA.ErrorMsg
+ processPa = const . Left . MA.ErrorMsg
$ "this mode does not accept positional arguments"
process :: Y.Config -> IO ()
diff --git a/lib/Penny/Brenner/OFX.hs b/lib/Penny/Brenner/OFX.hs
index ee0c925..889ff33 100644
--- a/lib/Penny/Brenner/OFX.hs
+++ b/lib/Penny/Brenner/OFX.hs
@@ -6,10 +6,12 @@
-- Description field. Information from the OFX Payee field is placed
-- into the Payee field of the Posting record.
-module Penny.Brenner.OFX (parser) where
+module Penny.Brenner.OFX
+ ( parser
+ , prepassParser
+ ) where
import Control.Applicative
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.List (isPrefixOf)
import qualified Data.OFX as O
import qualified Data.Text as X
@@ -19,7 +21,17 @@ import qualified Text.Parsec as P
-- | Parser for OFX files.
parser :: ( Y.ParserDesc, Y.ParserFn )
-parser = (Y.ParserDesc d, loadIncoming)
+parser = prepassParser id
+
+
+-- | Parser for OFX files. Any incoming data is first filtered
+-- through the given function. This allows you to correct broken
+-- OFX statements. For example, Bank of America issues OFX files that
+-- do not properly escape ampersands. Using this function you can
+-- change every ampersand to something properly escaped (or just
+-- change it to the word \"and\".)
+prepassParser :: (String -> String) -> ( Y.ParserDesc, Y.ParserFn )
+prepassParser f = (Y.ParserDesc d, loadIncoming f)
where
d = X.unlines
[ "Parses OFX 1.0-series files."
@@ -33,13 +45,14 @@ parser = (Y.ParserDesc d, loadIncoming)
]
loadIncoming
- :: Y.FitFileLocation
- -> IO (Ex.Exceptional String [Y.Posting])
-loadIncoming (Y.FitFileLocation fn) = do
- contents <- readFile fn
+ :: (String -> String)
+ -- ^ Prepass function
+ -> Y.FitFileLocation
+ -> IO (Either String [Y.Posting])
+loadIncoming pp (Y.FitFileLocation fn) = do
+ contents <- fmap pp $ readFile fn
return $
- ( Ex.mapException show
- . Ex.fromEither
+ ( either (Left . show) Right
$ P.parse O.ofxFile fn contents )
>>= O.transactions
>>= mapM txnToPosting
@@ -47,7 +60,7 @@ loadIncoming (Y.FitFileLocation fn) = do
txnToPosting
:: O.Transaction
- -> Ex.Exceptional String Y.Posting
+ -> Either String Y.Posting
txnToPosting t = Y.Posting
<$> pure (Y.Date ( T.utctDay . T.zonedTimeToUTC
. O.txDTPOSTED $ t))
@@ -65,8 +78,8 @@ txnToPosting t = Y.Posting
incDec =
if "-" `isPrefixOf` amtStr then Y.Decrease else Y.Increase
amt = case amtStr of
- [] -> Ex.throw "empty amount"
+ [] -> Left "empty amount"
x:xs -> let str = if x == '-' || x == '+' then xs else amtStr
- in Ex.fromMaybe ("could not parse amount: " ++ amtStr)
- $ Y.mkAmount str
+ in maybe (Left ("could not parse amount: " ++ amtStr))
+ Right $ Y.mkAmount str
diff --git a/lib/Penny/Brenner/Print.hs b/lib/Penny/Brenner/Print.hs
index 29893a5..49aa82e 100644
--- a/lib/Penny/Brenner/Print.hs
+++ b/lib/Penny/Brenner/Print.hs
@@ -7,7 +7,6 @@ module Penny.Brenner.Print (mode) where
import qualified Penny.Brenner.Types as Y
import qualified Penny.Brenner.Util as U
import qualified System.Console.MultiArg as MA
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Maybe (mapMaybe)
help :: String -> String
@@ -41,7 +40,7 @@ processor mayFa ls = do
doPrint (snd . Y.parser $ fa) ls
doPrint
- :: (Y.FitFileLocation -> IO (Ex.Exceptional String [Y.Posting]))
+ :: (Y.FitFileLocation -> IO (Either String [Y.Posting]))
-> [Arg]
-> IO ()
doPrint prsr ls = mapM_ f . mapMaybe toFile $ ls
@@ -49,9 +48,9 @@ doPrint prsr ls = mapM_ f . mapMaybe toFile $ ls
f file = do
r <- prsr file
case r of
- Ex.Exception s -> do
+ Left s -> do
fail $ "penny-fit print: error: " ++ s
- Ex.Success ps -> mapM putStr . map U.showPosting $ ps
+ Right ps -> mapM putStr . map U.showPosting $ ps
toFile a = case a of
ArgFile s -> Just (Y.FitFileLocation s)
diff --git a/lib/Penny/Brenner/Types.hs b/lib/Penny/Brenner/Types.hs
index 90ebddf..c31f946 100644
--- a/lib/Penny/Brenner/Types.hs
+++ b/lib/Penny/Brenner/Types.hs
@@ -28,7 +28,6 @@ module Penny.Brenner.Types
) where
import Control.Applicative ((<$>), (<*>))
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Data.Map as M
import qualified Data.Time as Time
import qualified Penny.Lincoln as L
@@ -289,7 +288,7 @@ data FitAcct = FitAcct
-- commodity and the quantity
, parser :: ( ParserDesc
- , FitFileLocation -> IO (Ex.Exceptional String [Posting]))
+ , FitFileLocation -> IO (Either String [Posting]))
-- ^ Parses a file of transactions from the financial
-- institution. The function must open the file and parse it. This
-- is in the IO monad not only because the function must open the
@@ -336,5 +335,5 @@ newtype AllowNew = AllowNew { unAllowNew :: Bool }
-- | All parsers must be of this type.
type ParserFn
= FitFileLocation
- -> IO (Ex.Exceptional String [Posting])
+ -> IO (Either String [Posting])
diff --git a/lib/Penny/Brenner/Util.hs b/lib/Penny/Brenner/Util.hs
index 62bad9e..9cda8d8 100644
--- a/lib/Penny/Brenner/Util.hs
+++ b/lib/Penny/Brenner/Util.hs
@@ -1,6 +1,5 @@
module Penny.Brenner.Util where
-import Control.Monad.Exception.Synchronous as Ex
import qualified Penny.Brenner.Types as Y
import qualified Data.ByteString as BS
import qualified System.IO.Error as IOE
@@ -47,8 +46,8 @@ loadDb (Y.AllowNew allowNew) (Y.DbLocation dbLoc) = do
then return []
else IOE.ioError e
Right g -> case readDbTuple g of
- Ex.Exception e -> fail e
- Ex.Success good -> return good
+ Left e -> fail e
+ Right good -> return good
-- | File version. Increment this when anything in the file format
-- changes.
@@ -60,12 +59,14 @@ brenner = "penny.brenner"
readDbTuple
:: BS.ByteString
- -> Ex.Exceptional String Y.DbList
+ -> Either String Y.DbList
readDbTuple bs = do
- (s, v, ls) <- Ex.fromEither $ S.decode bs
- Ex.assert "database file format not recognized." $ s == brenner
- Ex.assert "wrong database version." $ v == version
+ (s, v, ls) <- S.decode bs
+ assert "database file format not recognized." $ s == brenner
+ assert "wrong database version." $ v == version
return ls
+ where
+ assert e b = if b then Right () else Left e
saveDbTuple :: Y.DbList -> BS.ByteString
saveDbTuple ls = S.encode (brenner, version, ls)
diff --git a/lib/Penny/Cabin/Balance/Convert.hs b/lib/Penny/Cabin/Balance/Convert.hs
index 0bfc977..d102372 100644
--- a/lib/Penny/Cabin/Balance/Convert.hs
+++ b/lib/Penny/Cabin/Balance/Convert.hs
@@ -11,7 +11,6 @@ module Penny.Cabin.Balance.Convert (
) where
import Control.Applicative ((<$>), (<*>))
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Data.Tree as E
import qualified Data.Traversable as Tvbl
import qualified Penny.Cabin.Options as CO
@@ -68,7 +67,7 @@ convertBalance
-> L.DateTime
-> L.To
-> L.Balance
- -> Ex.Exceptional X.Text L.BottomLine
+ -> Either X.Text L.BottomLine
convertBalance db dt to bal = fmap mconcat r
where
r = mapM (convertOne db dt to) . M.assocs . L.unBalance $ bal
@@ -80,11 +79,11 @@ convertOne
-> L.DateTime
-> L.To
-> (L.Commodity, L.BottomLine)
- -> Ex.Exceptional X.Text L.BottomLine
+ -> Either X.Text L.BottomLine
convertOne db dt to (cty, bl) =
case bl of
L.Zero -> return L.Zero
- L.NonZero (L.Column dc qt) -> Ex.mapExceptional e g ex
+ L.NonZero (L.Column dc qt) -> either (Left . e) (Right . g) ex
where
ex = L.convertAsOf db dt to am
am = L.Amount qt cty
@@ -214,7 +213,7 @@ report
:: Opts
-> [L.PricePoint]
-> [(a, L.Posting)]
- -> Ex.Exceptional X.Text [Rb.Chunk]
+ -> Either X.Text [Rb.Chunk]
report os@(Opts eiFmt _ _ tgt _ txtFormats) ps bs = do
fstBl <- sumConvertSort os ps bs
return $ case eiFmt of
@@ -258,7 +257,7 @@ process rt chgrs defaultOpts fsf ls =
noDefault = X.pack "no default price found"
f = fromParsedOpts chgrs op'
pr fmt ts pps = do
- rptOpts <- Ex.fromMaybe noDefault $ f pps fmt
+ rptOpts <- maybe (Left noDefault) Right $ f pps fmt
let boxes = fsf ts
report rptOpts pps boxes
in (posArgs, pr)
@@ -272,7 +271,7 @@ sumConvertSort
:: Opts
-> [L.PricePoint]
-> [(a, L.Posting)]
- -> Ex.Exceptional X.Text ForestAndBL
+ -> Either X.Text ForestAndBL
sumConvertSort os ps bs = mkResult <$> convertedFrst <*> convertedTot
where
(Opts _ szb str tgt dt _) = os
diff --git a/lib/Penny/Cabin/Balance/Convert/Parser.hs b/lib/Penny/Cabin/Balance/Convert/Parser.hs
index 14818a0..b00455a 100644
--- a/lib/Penny/Cabin/Balance/Convert/Parser.hs
+++ b/lib/Penny/Cabin/Balance/Convert/Parser.hs
@@ -8,7 +8,6 @@ module Penny.Cabin.Balance.Convert.Parser (
) where
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Data.Text as X
import qualified Penny.Cabin.Options as CO
import qualified Penny.Cabin.Parsers as P
@@ -67,7 +66,7 @@ parseCommodity = C.OptSpec ["commodity"] "c" (C.OneArgE f)
where
f a1 =
case Parsec.parse Pc.lvl1Cmdty "" (X.pack a1) of
- Left _ -> Ex.throw . C.ErrorMsg $ "invalid commodity"
+ Left _ -> Left . C.ErrorMsg $ "invalid commodity"
Right g -> return $ \os -> os { target = ManualTarget . L.To $ g }
parseAuto :: C.OptSpec (Opts -> Opts)
@@ -80,7 +79,7 @@ parseDate = C.OptSpec ["date"] "d" (C.OneArgE f)
where
f a1 =
case Parsec.parse Pc.dateTime "" (X.pack a1) of
- Left _ -> Ex.throw . C.ErrorMsg $ "invalid date"
+ Left _ -> Left . C.ErrorMsg $ "invalid date"
Right g -> return $ \os -> os { dateTime = g }
parseSort :: C.OptSpec (Opts -> Opts)
@@ -107,5 +106,5 @@ parseRound = C.OptSpec ["round"] "r" (C.OneArgE f)
f a = do
i <- C.reader a
case L.nonNegative i of
- Nothing -> Ex.throw . C.ErrorMsg $ "argument is negative"
+ Nothing -> Left . C.ErrorMsg $ "argument is negative"
Just g -> return $ \o -> o { percentRpt = Just (RoundTo g) }
diff --git a/lib/Penny/Cabin/Interface.hs b/lib/Penny/Cabin/Interface.hs
index e961033..41818d0 100644
--- a/lib/Penny/Cabin/Interface.hs
+++ b/lib/Penny/Cabin/Interface.hs
@@ -4,7 +4,6 @@ module Penny.Cabin.Interface where
import qualified Data.Prednote.Expressions as Exp
import qualified Penny.Cabin.Scheme as S
-import Control.Monad.Exception.Synchronous (Exceptional)
import qualified Data.Text as X
import Text.Matchers (CaseSensitive)
import qualified Text.Matchers as TM
@@ -31,7 +30,7 @@ type ArgsAndReport = ([PosArg], PrintReport)
-- indicated with a Text. The name of the executable and the word
-- @error@ will be prepended to this Text; otherwise, it is printed
-- as-is, so be sure to include any trailing newline if needed.
-type ParseResult = Exceptional X.Text ArgsAndReport
+type ParseResult = Either X.Text ArgsAndReport
type PrintReport
= (L.Amount L.Qty -> X.Text)
@@ -48,7 +47,7 @@ type PrintReport
-- ^ PricePoints to be included in the report
- -> Exceptional X.Text [R.Chunk]
+ -> Either X.Text [R.Chunk]
-- ^ The exception type is a strict Text, containing the error
-- message. The success type is a list of either a Chunk or a PreChunk
-- containing the resulting report. This allows for errors after the
@@ -65,7 +64,7 @@ type MkReport
-- case sensitivity (this may have been changed in the filtering
-- options)
- -> (CaseSensitive -> X.Text -> Exceptional X.Text TM.Matcher)
+ -> (CaseSensitive -> X.Text -> Either X.Text TM.Matcher)
-- ^ Result from previous parsers indicating the matcher factory the
-- user wishes to use
diff --git a/lib/Penny/Cabin/Posts.hs b/lib/Penny/Cabin/Posts.hs
index fc49bda..64ba9a4 100644
--- a/lib/Penny/Cabin/Posts.hs
+++ b/lib/Penny/Cabin/Posts.hs
@@ -53,7 +53,6 @@ module Penny.Cabin.Posts
) where
import Control.Applicative ((<$>), (<*>))
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.List.Split (chunksOf)
import qualified Data.Either as Ei
import qualified Data.Text as X
@@ -121,7 +120,7 @@ zincReport opts rt = (helpStr opts, md)
specs
:: Sh.Runtime
- -> [MA.OptSpec (Either String (P.State -> Ex.Exceptional X.Text P.State))]
+ -> [MA.OptSpec (Either String (P.State -> Either X.Text P.State))]
specs = map (fmap Right) . P.allSpecs
@@ -132,8 +131,8 @@ process
-> E.Changers
-> Exp.ExprDesc
-> ([L.Transaction] -> [(Ly.LibertyMeta, L.Posting)])
- -> [Either String (P.State -> Ex.Exceptional X.Text P.State)]
- -> Ex.Exceptional X.Text I.ArgsAndReport
+ -> [Either String (P.State -> Either X.Text P.State)]
+ -> Either X.Text I.ArgsAndReport
process os cs fty ch expr fsf ls =
let (posArgs, clOpts) = Ei.partitionEithers ls
pState = newParseState cs fty expr os
@@ -212,7 +211,7 @@ type Error = X.Text
getPredicate
:: Exp.ExprDesc
-> [Exp.Token ((Ly.LibertyMeta, L.Posting))]
- -> Ex.Exceptional Error (Pe.Pdct ((Ly.LibertyMeta, L.Posting)))
+ -> Either Error (Pe.Pdct ((Ly.LibertyMeta, L.Posting)))
getPredicate d ts =
case ts of
[] -> return $ Pe.always
@@ -517,8 +516,6 @@ helpStr o = unlines $
, " Use \"within\" matcher"
, "--pcre"
, " Use \"pcre\" matcher"
- , "--posix"
- , " Use \"posix\" matcher"
, "--exact"
, " Use \"exact\" matcher"
, ""
diff --git a/lib/Penny/Cabin/Posts/Parser.hs b/lib/Penny/Cabin/Posts/Parser.hs
index c08b41e..832d4ff 100644
--- a/lib/Penny/Cabin/Posts/Parser.hs
+++ b/lib/Penny/Cabin/Posts/Parser.hs
@@ -10,7 +10,6 @@ module Penny.Cabin.Posts.Parser
import Control.Applicative ((<$>), pure, (<*>),
Applicative)
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Char (toLower)
import qualified Data.Foldable as Fdbl
import Data.Monoid ((<>))
@@ -52,7 +51,7 @@ data State = State
type Error = X.Text
allSpecs
- :: S.Runtime -> [MA.OptSpec (State -> Ex.Exceptional Error State)]
+ :: S.Runtime -> [MA.OptSpec (State -> Either Error State)]
allSpecs rt =
operand rt
++ boxFilters
@@ -74,7 +73,7 @@ allSpecs rt =
operand
:: S.Runtime
- -> [MA.OptSpec (State -> Ex.Exceptional Error State)]
+ -> [MA.OptSpec (State -> Either Error State)]
operand rt = map (fmap f) (Ly.operandSpecs (S.currentTime rt))
where
f lyFn st = do
@@ -94,7 +93,7 @@ optBoxSerial
-> (Ly.LibertyMeta -> Int)
-- ^ Pulls the serial from the PostMeta
- -> C.OptSpec (State -> Ex.Exceptional Error State)
+ -> C.OptSpec (State -> Either Error State)
optBoxSerial nm f = C.OptSpec [nm] "" (C.TwoArg g)
where
@@ -107,27 +106,27 @@ optBoxSerial nm f = C.OptSpec [nm] "" (C.TwoArg g)
let tok = Exp.operand pd
return $ st { tokens = tokens st ++ [tok] }
-optFilteredNum :: C.OptSpec (State -> Ex.Exceptional Error State)
+optFilteredNum :: C.OptSpec (State -> Either Error State)
optFilteredNum = optBoxSerial "filtered" f
where
f = L.forward . Ly.unFilteredNum . Ly.filteredNum
-optRevFilteredNum :: C.OptSpec (State -> Ex.Exceptional Error State)
+optRevFilteredNum :: C.OptSpec (State -> Either Error State)
optRevFilteredNum = optBoxSerial "revFiltered" f
where
f = L.backward . Ly.unFilteredNum . Ly.filteredNum
-optSortedNum :: C.OptSpec (State -> Ex.Exceptional Error State)
+optSortedNum :: C.OptSpec (State -> Either Error State)
optSortedNum = optBoxSerial "sorted" f
where
f = L.forward . Ly.unSortedNum . Ly.sortedNum
-optRevSortedNum :: C.OptSpec (State -> Ex.Exceptional Error State)
+optRevSortedNum :: C.OptSpec (State -> Either Error State)
optRevSortedNum = optBoxSerial "revSorted" f
where
f = L.backward . Ly.unSortedNum . Ly.sortedNum
-boxFilters :: [C.OptSpec (State -> Ex.Exceptional Error State)]
+boxFilters :: [C.OptSpec (State -> Either Error State)]
boxFilters =
[ optFilteredNum
, optRevFilteredNum
@@ -136,7 +135,7 @@ boxFilters =
]
-parsePostFilter :: [C.OptSpec (State -> Ex.Exceptional Error State)]
+parsePostFilter :: [C.OptSpec (State -> Either Error State)]
parsePostFilter = [fmap f optH, fmap f optT]
where
(optH, optT) = Ly.postFilterSpecs
@@ -161,14 +160,14 @@ operator = map (fmap f) Ly.operatorSpecs
where
f oo st = st { tokens = tokens st ++ [oo] }
-parseWidth :: C.OptSpec (State -> Ex.Exceptional Error State)
+parseWidth :: C.OptSpec (State -> Either Error State)
parseWidth = C.OptSpec ["width"] "" (C.OneArg f)
where
f a1 st = do
i <- Ly.parseInt a1
return $ st { width = Ty.ReportWidth i }
-parseField :: String -> Ex.Exceptional Error (F.Fields Bool)
+parseField :: String -> Either Error (F.Fields Bool)
parseField str =
let lower = map toLower str
checkField s =
@@ -177,17 +176,17 @@ parseField str =
else (s, False)
flds = checkField <$> F.fieldNames
in case checkFields flds of
- Ex.Exception e -> case e of
- NoMatchingFields -> Ex.throw
+ Left e -> case e of
+ NoMatchingFields -> Left
$ "no field matches the name \"" <> X.pack str <> "\"\n"
- MultipleMatchingFields ts -> Ex.throw
+ MultipleMatchingFields ts -> Left
$ "multiple fields match the name \"" <> X.pack str
<> "\" matches: " <> mtchs <> "\n"
where
mtchs = X.intercalate " "
. map (\x -> "\"" <> x <> "\"")
$ ts
- Ex.Success g -> return g
+ Right g -> return g
-- | Turns a field on if it is True.
@@ -221,7 +220,7 @@ fieldOff old new = f <$> old <*> new
f o False = o
f _ True = False
-showField :: C.OptSpec (State -> Ex.Exceptional Error State)
+showField :: C.OptSpec (State -> Either Error State)
showField = C.OptSpec ["show"] "" (C.OneArg f)
where
f a1 st = do
@@ -229,7 +228,7 @@ showField = C.OptSpec ["show"] "" (C.OneArg f)
let newFl = fieldOn (fields st) fl
return $ st { fields = newFl }
-hideField :: C.OptSpec (State -> Ex.Exceptional Error State)
+hideField :: C.OptSpec (State -> Either Error State)
hideField = C.OptSpec ["hide"] "" (C.OneArg f)
where
f a1 st = do
@@ -275,12 +274,12 @@ data BadFieldError
-- | Checks the fields with the True value to ensure there is only one.
checkFields ::
F.Fields (String, Bool)
- -> Ex.Exceptional BadFieldError (F.Fields Bool)
+ -> Either BadFieldError (F.Fields Bool)
checkFields fs =
let f (s, b) ls = if b then s:ls else ls
in case Fdbl.foldr f [] fs of
- [] -> Ex.throw NoMatchingFields
+ [] -> Left NoMatchingFields
_:[] -> return (snd <$> fs)
- ms -> Ex.throw . MultipleMatchingFields . map X.pack $ ms
+ ms -> Left . MultipleMatchingFields . map X.pack $ ms
diff --git a/lib/Penny/Cabin/Scheme.hs b/lib/Penny/Cabin/Scheme.hs
index 176c67d..ed11f1b 100644
--- a/lib/Penny/Cabin/Scheme.hs
+++ b/lib/Penny/Cabin/Scheme.hs
@@ -55,7 +55,7 @@ data Scheme = Scheme
-- as @for dark background terminals@
, changers :: Changers
- } deriving Show
+ }
getEvenOdd :: EvenOdd -> EvenAndOdd a -> a
diff --git a/lib/Penny/Copper/Parsec.hs b/lib/Penny/Copper/Parsec.hs
index 492444a..9e90caf 100644
--- a/lib/Penny/Copper/Parsec.hs
+++ b/lib/Penny/Copper/Parsec.hs
@@ -13,7 +13,6 @@ import Control.Applicative.Permutation (runPerms, maybeAtom)
import Control.Applicative ((<$>), (<$), (<*>), (*>), (<*),
(<|>), optional)
import Control.Monad (replicateM, when)
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.List.NonEmpty (NonEmpty((:|)))
import qualified Penny.Lincoln as L
import qualified Penny.Steel.Sums as S
@@ -509,13 +508,13 @@ parse
:: Text
-- ^ Contents of file to be parsed
- -> Ex.Exceptional String [I.ParsedItem]
+ -> Either String [I.ParsedItem]
-- ^ Returns items if successfully parsed; otherwise, returns an
-- error message.
parse s =
let parser = P.spaces *> P.many item <* P.spaces <* P.eof
- in Ex.mapException show . Ex.fromEither
+ in either (Left . show) Right
$ P.parse parser "" s
@@ -543,16 +542,16 @@ parseStdinOnly :: IO (L.Filename, [I.ParsedItem])
parseStdinOnly = do
txt <- getStdin
case parse txt of
- Ex.Exception err -> handleParseError "standard input" err
- Ex.Success g -> return (L.Filename . X.pack $ "<stdin>", g)
+ Left err -> handleParseError "standard input" err
+ Right g -> return (L.Filename . X.pack $ "<stdin>", g)
parseFromFilename :: String -> IO (L.Filename, [I.ParsedItem])
parseFromFilename s = do
(fn, txt) <- getFileContentsStdin s
case parse txt of
- Ex.Exception err ->
+ Left err ->
handleParseError (X.unpack . L.unFilename $ fn) err
- Ex.Success g -> return (fn, g)
+ Right g -> return (fn, g)
handleParseError
:: String
diff --git a/lib/Penny/Liberty.hs b/lib/Penny/Liberty.hs
index 6846cde..2da6f59 100644
--- a/lib/Penny/Liberty.hs
+++ b/lib/Penny/Liberty.hs
@@ -51,7 +51,6 @@ module Penny.Liberty (
import Control.Arrow (first, second)
import Control.Applicative ((<*>), (<$>), pure, Applicative)
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Char (toUpper)
import Data.Monoid ((<>))
import Data.List (sortBy)
@@ -109,7 +108,7 @@ data LibertyMeta =
parsePredicate
:: X.ExprDesc
-> [X.Token a]
- -> Ex.Exceptional Error (E.Pdct a)
+ -> Either Error (E.Pdct a)
parsePredicate d ls = case ls of
[] -> return E.always
_ -> X.parseExpression d ls
@@ -177,7 +176,7 @@ indentAmt = 4
type MatcherFactory
= CaseSensitive
-> Text
- -> Ex.Exceptional Text TM.Matcher
+ -> Either Text TM.Matcher
newtype ListLength = ListLength { unListLength :: Int }
deriving (Eq, Ord, Show)
@@ -211,10 +210,10 @@ getMatcher
:: String
-> CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error TM.Matcher
+ -> Either Error TM.Matcher
getMatcher s cs f
- = Ex.mapException mkError
+ = either (Left . mkError) Right
$ f cs (pack s)
where
mkError eMsg = "bad pattern: \"" <> pack s <> " - " <> eMsg
@@ -226,16 +225,15 @@ getMatcher s cs f
parseComparer
:: String
-> (Ordering -> E.Pdct a)
- -> Ex.Exceptional Error (E.Pdct a)
-parseComparer s f = Ex.fromMaybe ("bad comparer: " <> pack s <> "\n")
- $ E.parseComparer (pack s) f
+ -> Either Error (E.Pdct a)
+parseComparer s f = maybe (Left ("bad comparer: " <> pack s <> "\n"))
+ Right $ E.parseComparer (pack s) f
-- | Parses a date from the command line. On failure, throws back the
-- error message from the failed parse.
-parseDate :: String -> Ex.Exceptional Error Time.UTCTime
+parseDate :: String -> Either Error Time.UTCTime
parseDate arg =
- Ex.mapExceptional err L.toUTC
- . Ex.fromEither
+ either (Left . err) (Right . L.toUTC)
. parse Pc.dateTime ""
. pack
$ arg
@@ -245,7 +243,7 @@ parseDate arg =
type Operand = E.Pdct L.Posting
-- | OptSpec for a date.
-date :: OptSpec (Ex.Exceptional Error Operand)
+date :: OptSpec (Either Error Operand)
date = C.OptSpec ["date"] ['d'] (C.TwoArg f)
where
f a1 a2 = do
@@ -259,11 +257,11 @@ current dt = C.OptSpec ["current"] [] (C.NoArg f)
f = E.or [P.date LT (L.toUTC dt), P.date EQ (L.toUTC dt)]
-- | Parses exactly one integer; fails if it cannot read exactly one.
-parseInt :: String -> Ex.Exceptional Error Int
+parseInt :: String -> Either Error Int
parseInt t =
case reads t of
((i, ""):[]) -> return i
- _ -> Ex.throw $ "could not parse integer: \"" <> pack t <> "\"\n"
+ _ -> Left $ "could not parse integer: \"" <> pack t <> "\"\n"
-- | Creates options that add an operand that matches the posting if a
@@ -280,7 +278,7 @@ patternOption ::
-> OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
patternOption str mc f = C.OptSpec [str] so (C.OneArg g)
where
so = maybe [] (:[]) mc
@@ -291,7 +289,7 @@ patternOption str mc f = C.OptSpec [str] so (C.OneArg g)
-- colon-separated account name.
account :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
account = C.OptSpec ["account"] "a" (C.OneArg f)
where
f a1 cs fty
@@ -303,7 +301,7 @@ account = C.OptSpec ["account"] "a" (C.OneArg f)
-- level matches.
accountLevel :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
accountLevel = C.OptSpec ["account-level"] "" (C.TwoArg f)
where
f a1 a2 cs fty
@@ -314,49 +312,49 @@ accountLevel = C.OptSpec ["account-level"] "" (C.TwoArg f)
-- a single sub-account name at any level.
accountAny :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
accountAny = patternOption "account-any" Nothing P.accountAny
-- | The payee option; returns True if the matcher matches the payee
-- name.
payee :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
payee = patternOption "payee" (Just 'p') P.payee
tag :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
tag = patternOption "tag" (Just 't') P.tag
number :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
number = patternOption "number" (Just 'n') P.number
flag :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
flag = patternOption "flag" (Just 'f') P.flag
commodity :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
commodity = patternOption "commodity" (Just 'y') P.commodity
filename :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
filename = patternOption "filename" Nothing P.filename
postingMemo :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
postingMemo = patternOption "posting-memo" Nothing P.postingMemo
transactionMemo :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
transactionMemo = patternOption "transaction-memo"
Nothing P.transactionMemo
@@ -366,14 +364,14 @@ debit = C.OptSpec ["debit"] [] (C.NoArg P.debit)
credit :: OptSpec Operand
credit = C.OptSpec ["credit"] [] (C.NoArg P.credit)
-qtyOption :: OptSpec (Ex.Exceptional Error Operand)
+qtyOption :: OptSpec (Either Error Operand)
qtyOption = C.OptSpec ["qty"] "q" (C.TwoArg f)
where
f a1 a2 = do
qt <- parseQty a2
parseComparer a1 (flip P.qty qt)
parseQty a = case parse Pc.unquotedQtyRepWithSpaces "" (pack a) of
- Left _ -> Ex.throw $ "failed to parse quantity"
+ Left _ -> Left $ "failed to parse quantity"
Right g -> pure . L.toQty $ g
@@ -388,8 +386,8 @@ serialOption ::
-> String
-- ^ Name of the command line option, such as @global-transaction@
- -> ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+ -> ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
-- ^ Parses both descending and ascending serial options.
serialOption getSerial n = (osA, osD)
@@ -420,8 +418,8 @@ siblingSerialOption
-> (Int -> Ordering -> E.Pdct L.Posting)
-- ^ Function that returns a Pdct for reverse serial
- -> ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+ -> ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
-- ^ Parses both descending and ascending serial options.
siblingSerialOption n fFwd fBak = (osA, osD)
@@ -443,26 +441,26 @@ addPrefix pre suf = pre ++ suf' where
"" -> ""
x:xs -> toUpper x : xs
-globalTransaction :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+globalTransaction :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
globalTransaction =
let f = fmap L.unGlobalTransaction . Q.globalTransaction
in serialOption f "globalTransaction"
-globalPosting :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+globalPosting :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
globalPosting =
let f = fmap L.unGlobalPosting . Q.globalPosting
in serialOption f "globalPosting"
-filePosting :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+filePosting :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
filePosting =
let f = fmap L.unFilePosting . Q.filePosting
in serialOption f "filePosting"
-fileTransaction :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+fileTransaction :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
fileTransaction =
let f = fmap L.unFileTransaction . Q.fileTransaction
in serialOption f "fileTransaction"
@@ -472,7 +470,7 @@ operandSpecs
:: L.DateTime
-> [OptSpec (CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)]
+ -> Either Error Operand)]
operandSpecs dt =
[ fmap (const . const) date
@@ -509,7 +507,7 @@ operandSpecs dt =
serialSpecs :: [OptSpec (CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)]
+ -> Either Error Operand)]
serialSpecs
= concat
$ [unDouble]
@@ -520,9 +518,9 @@ serialSpecs
unDouble
:: Functor f
- => (f (Ex.Exceptional Error a),
- f (Ex.Exceptional Error a ))
- -> [ f (x -> y -> Ex.Exceptional Error a) ]
+ => (f (Either Error a),
+ f (Either Error a ))
+ -> [ f (x -> y -> Either Error a) ]
unDouble (o1, o2) = [fmap (const . const) o1, fmap (const . const) o2]
@@ -535,7 +533,7 @@ unDouble (o1, o2) = [fmap (const . const) o1, fmap (const . const) o2]
data BadHeadTailError = BadHeadTailError Text
deriving Show
-optHead :: OptSpec (Ex.Exceptional Error PostFilterFn)
+optHead :: OptSpec (Either Error PostFilterFn)
optHead = C.OptSpec ["head"] [] (C.OneArg f)
where
f a = do
@@ -543,7 +541,7 @@ optHead = C.OptSpec ["head"] [] (C.OneArg f)
let g _ ii = ii < (ItemIndex num)
return g
-optTail :: OptSpec (Ex.Exceptional Error PostFilterFn)
+optTail :: OptSpec (Either Error PostFilterFn)
optTail = C.OptSpec ["tail"] [] (C.OneArg f)
where
f a = do
@@ -552,8 +550,8 @@ optTail = C.OptSpec ["tail"] [] (C.OneArg f)
return g
postFilterSpecs
- :: ( OptSpec (Ex.Exceptional Error PostFilterFn)
- , OptSpec (Ex.Exceptional Error PostFilterFn))
+ :: ( OptSpec (Either Error PostFilterFn)
+ , OptSpec (Either Error PostFilterFn))
postFilterSpecs = (optHead, optTail)
------------------------------------------------------------
@@ -576,17 +574,15 @@ within =
return (TM.within c t)
pcre :: OptSpec MatcherFactory
-pcre = C.OptSpec ["pcre"] "r" (C.NoArg TM.pcre)
-
-posix :: OptSpec MatcherFactory
-posix = C.OptSpec ["posix"] "" (C.NoArg TM.tdfa)
+pcre = C.OptSpec ["pcre"] "r"
+ (C.NoArg (\cs x -> TM.pcre cs x))
exact :: OptSpec MatcherFactory
exact = C.OptSpec ["exact"] "x" . C.NoArg $ \c t ->
return (TM.exact c t)
matcherSelectSpecs :: [OptSpec MatcherFactory]
-matcherSelectSpecs = [within, pcre, posix, exact]
+matcherSelectSpecs = [within, pcre, exact]
caseSelectSpecs :: [OptSpec CaseSensitive]
caseSelectSpecs = [parseInsensitive, parseSensitive]
@@ -641,26 +637,26 @@ verboseFilter = C.OptSpec ["verbose-filter"] "" (C.NoArg ())
-- Siblings
--
-sGlobalPosting :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+sGlobalPosting :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
sGlobalPosting =
siblingSerialOption "globalPosting"
PS.fwdGlobalPosting PS.backGlobalPosting
-sFilePosting :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+sFilePosting :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
sFilePosting =
siblingSerialOption "filePosting"
PS.fwdFilePosting PS.backFilePosting
-sGlobalTransaction :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+sGlobalTransaction :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
sGlobalTransaction =
siblingSerialOption "globalTransaction"
PS.fwdGlobalTransaction PS.backGlobalTransaction
-sFileTransaction :: ( OptSpec (Ex.Exceptional Error Operand)
- , OptSpec (Ex.Exceptional Error Operand) )
+sFileTransaction :: ( OptSpec (Either Error Operand)
+ , OptSpec (Either Error Operand) )
sFileTransaction =
siblingSerialOption "filePosting"
PS.fwdFileTransaction PS.backFileTransaction
@@ -668,7 +664,7 @@ sFileTransaction =
sAccount :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
sAccount = C.OptSpec ["s-account"] "" (C.OneArg f)
where
f a1 cs fty = fmap PS.account
@@ -676,7 +672,7 @@ sAccount = C.OptSpec ["s-account"] "" (C.OneArg f)
sAccountLevel :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
sAccountLevel = C.OptSpec ["s-account-level"] "" (C.TwoArg f)
where
f a1 a2 cs fty
@@ -684,39 +680,39 @@ sAccountLevel = C.OptSpec ["s-account-level"] "" (C.TwoArg f)
sAccountAny :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
sAccountAny = patternOption "s-account-any" Nothing PS.accountAny
-- | The payee option; returns True if the matcher matches the payee
-- name.
sPayee :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
sPayee = patternOption "s-payee" (Just 'p') PS.payee
sTag :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
sTag = patternOption "s-tag" (Just 't') PS.tag
sNumber :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand )
+ -> Either Error Operand )
sNumber = patternOption "s-number" Nothing PS.number
sFlag :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
sFlag = patternOption "s-flag" Nothing PS.flag
sCommodity :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
sCommodity = patternOption "s-commodity" Nothing PS.commodity
sPostingMemo :: OptSpec ( CaseSensitive
-> MatcherFactory
- -> Ex.Exceptional Error Operand)
+ -> Either Error Operand)
sPostingMemo = patternOption "s-posting-memo" Nothing PS.postingMemo
sDebit :: OptSpec Operand
@@ -725,14 +721,14 @@ sDebit = C.OptSpec ["s-debit"] [] (C.NoArg PS.debit)
sCredit :: OptSpec Operand
sCredit = C.OptSpec ["s-credit"] [] (C.NoArg PS.credit)
-sQtyOption :: OptSpec (Ex.Exceptional Error Operand)
+sQtyOption :: OptSpec (Either Error Operand)
sQtyOption = C.OptSpec ["s-qty"] [] (C.TwoArg f)
where
f a1 a2 = do
qt <- parseQty a2
parseComparer a1 (flip PS.qty qt)
parseQty a = case parse Pc.unquotedQtyRepWithSpaces "" (pack a) of
- Left _ -> Ex.throw "could not parse quantity"
+ Left _ -> Left "could not parse quantity"
Right g -> pure . L.toQty $ g
--
diff --git a/lib/Penny/Lincoln/Bits/Qty.hs b/lib/Penny/Lincoln/Bits/Qty.hs
index 508b2b4..e76fd08 100644
--- a/lib/Penny/Lincoln/Bits/Qty.hs
+++ b/lib/Penny/Lincoln/Bits/Qty.hs
@@ -65,7 +65,6 @@ module Penny.Lincoln.Bits.Qty
-- # Imports
import Control.Applicative ((<|>))
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Text (Text)
import qualified Data.Text as X
import Data.Ord(Down(..), comparing)
@@ -765,12 +764,14 @@ largestRemainderMethod
largestRemainderMethod ts pvs =
let err s = error $ "largestRemainderMethod: error: " ++ s
- in Ex.resolve err $ do
- Ex.assert "TotalSeats not positive" (ts > 0)
- Ex.assert "sum of [PartyVotes] not positive" (sum pvs > 0)
- Ex.assert "negative member of [PartyVotes]" (minimum pvs >= 0)
+ in either err id $ do
+ assert "TotalSeats not positive" (ts > 0)
+ assert "sum of [PartyVotes] not positive" (sum pvs > 0)
+ assert "negative member of [PartyVotes]" (minimum pvs >= 0)
return (allocRemainder ts . allocAuto ts $ pvs)
+assert :: e -> Bool -> Either e ()
+assert e b = if b then Right () else Left e
autoAndRemainder
:: TotSeats -> TotVotes -> PartyVotes -> (AutoSeats, Remainder)
diff --git a/lib/Penny/Lincoln/Matchers.hs b/lib/Penny/Lincoln/Matchers.hs
index 7cc0fff..aeea28f 100644
--- a/lib/Penny/Lincoln/Matchers.hs
+++ b/lib/Penny/Lincoln/Matchers.hs
@@ -3,7 +3,6 @@
module Penny.Lincoln.Matchers where
import qualified Data.Text as X
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Text.Matchers as MT
-- | A function that makes Matchers.
@@ -15,7 +14,7 @@ type Factory
-- ^ The pattern to use when testing for a match. For example, this
-- might be a regular expression, or simply the text to be matched.
- -> Ex.Exceptional X.Text MT.Matcher
+ -> Either X.Text MT.Matcher
-- ^ Sometimes producing a matcher might fail; for example, the user
-- might have supplied a bad pattern. If so, an exception is
-- returned. On success, a Matcher is returned.
diff --git a/lib/Penny/Lincoln/PriceDb.hs b/lib/Penny/Lincoln/PriceDb.hs
index f32a3c8..49312cc 100644
--- a/lib/Penny/Lincoln/PriceDb.hs
+++ b/lib/Penny/Lincoln/PriceDb.hs
@@ -12,7 +12,6 @@ module Penny.Lincoln.PriceDb (
convertAsOf
) where
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Data.Map as M
import qualified Data.Time as T
import qualified Penny.Lincoln.Bits as B
@@ -65,17 +64,17 @@ getPrice ::
-> B.From
-> B.To
-> B.DateTime
- -> Ex.Exceptional PriceDbError B.CountPerUnit
+ -> Either PriceDbError B.CountPerUnit
getPrice (PriceDb db) fr to dt = do
let utc = B.toUTC dt
- toMap <- Ex.fromMaybe FromNotFound $ M.lookup fr db
- cpuMap <- Ex.fromMaybe ToNotFound $ M.lookup to toMap
+ toMap <- maybe (Left FromNotFound) Right $ M.lookup fr db
+ cpuMap <- maybe (Left ToNotFound) Right $ M.lookup to toMap
let (lower, exact, _) = M.splitLookup utc cpuMap
case exact of
Just c -> return c
Nothing ->
if M.null lower
- then Ex.throw CpuNotFound
+ then Left CpuNotFound
else return . snd . M.findMax $ lower
@@ -90,7 +89,7 @@ convertAsOf ::
-> B.DateTime
-> B.To
-> B.Amount q
- -> Ex.Exceptional PriceDbError B.Qty
+ -> Either PriceDbError B.Qty
convertAsOf db dt to (B.Amount qt fr)
| fr == B.unTo to = return . B.toQty $ qt
| otherwise = do
diff --git a/lib/Penny/Lincoln/Serial.hs b/lib/Penny/Lincoln/Serial.hs
index 3fb6507..9cbe236 100644
--- a/lib/Penny/Lincoln/Serial.hs
+++ b/lib/Penny/Lincoln/Serial.hs
@@ -9,8 +9,6 @@ import Control.Monad (ap, liftM, replicateM_)
import Data.Traversable (Traversable)
import qualified Data.Traversable as Tr
import qualified Data.Foldable as Fdbl
-import GHC.Generics (Generic)
-import Data.Binary (Binary)
data SerialSt = SerialSt
{ nextFwd :: Int
@@ -21,9 +19,7 @@ data SerialSt = SerialSt
data Serial = Serial
{ forward :: Int
, backward :: Int
- } deriving (Eq, Show, Ord, Generic)
-
-instance Binary Serial
+ } deriving (Eq, Show, Ord)
newtype GenSerial a = GenSerial (SerialSt -> (a, SerialSt))
diff --git a/lib/Penny/Steel/Sums.hs b/lib/Penny/Steel/Sums.hs
index b2af8bd..3f1bd71 100644
--- a/lib/Penny/Steel/Sums.hs
+++ b/lib/Penny/Steel/Sums.hs
@@ -4,25 +4,18 @@
module Penny.Steel.Sums where
-import Data.Binary (Binary)
-import GHC.Generics (Generic)
-
data S3 a b c
= S3a a
| S3b b
| S3c c
- deriving (Eq, Ord, Show, Generic)
-
-instance (Binary a, Binary b, Binary c) => Binary (S3 a b c)
+ deriving (Eq, Ord, Show)
data S4 a b c d
= S4a a
| S4b b
| S4c c
| S4d d
- deriving (Eq, Ord, Show, Generic)
-
-instance (Binary a, Binary b, Binary c, Binary d) => Binary (S4 a b c d)
+ deriving (Eq, Ord, Show)
partitionS3 :: [S3 a b c] -> ([a], [b], [c])
partitionS3 = foldr f ([], [], [])
diff --git a/lib/Penny/Wheat.hs b/lib/Penny/Wheat.hs
index 3a70cc8..8eaa335 100644
--- a/lib/Penny/Wheat.hs
+++ b/lib/Penny/Wheat.hs
@@ -24,7 +24,6 @@ module Penny.Wheat
, main
) where
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Either (partitionEithers)
import Data.Maybe (mapMaybe)
import qualified Penny.Copper as Cop
@@ -110,16 +109,16 @@ data WheatConf = WheatConf
}
-parseBaseTime :: String -> Ex.Exceptional MA.InputError Time.UTCTime
+parseBaseTime :: String -> Either MA.InputError Time.UTCTime
parseBaseTime s = case Parsec.parse CP.dateTime "" (X.pack s) of
- Left e -> Ex.throw (MA.ErrorMsg $ "could not parse date: " ++ show e)
+ Left e -> Left (MA.ErrorMsg $ "could not parse date: " ++ show e)
Right g -> return . L.toUTC $ g
-parseRegexp :: String -> Ex.Exceptional MA.InputError (TT.Name -> Bool)
+parseRegexp :: String -> Either MA.InputError (TT.Name -> Bool)
parseRegexp s = case M.pcre M.Sensitive (X.pack s) of
- Ex.Exception e -> Ex.throw . MA.ErrorMsg $
+ Left e -> Left . MA.ErrorMsg $
"could not parse regular expression: " ++ X.unpack e
- Ex.Success m -> return . M.match $ m
+ Right m -> return . M.match $ m
allOpts :: [MA.OptSpec (WheatConf -> WheatConf)]
allOpts =
diff --git a/lib/Penny/Zinc.hs b/lib/Penny/Zinc.hs
index 7d447ef..5434639 100644
--- a/lib/Penny/Zinc.hs
+++ b/lib/Penny/Zinc.hs
@@ -24,7 +24,6 @@ import qualified Penny.Steel.Sums as Su
import Control.Applicative ((<*>), pure, (<$))
import qualified Control.Monad.Trans.State as St
-import qualified Control.Monad.Exception.Synchronous as Ex
import Data.Char (toUpper, toLower)
import Data.Either (partitionEithers)
import Data.List (isPrefixOf)
@@ -68,7 +67,6 @@ newtype ColorToFile = ColorToFile { unColorToFile :: Bool }
data Matcher
= Within
| Exact
- | TDFA
| PCRE
deriving (Eq, Show)
@@ -160,12 +158,12 @@ type Error = Text
data OptResult
= ROperand (M.CaseSensitive
-> Ly.MatcherFactory
- -> Ex.Exceptional Ly.Error Ly.Operand)
- | RPostFilter (Ex.Exceptional Ly.Error Ly.PostFilterFn)
+ -> Either Ly.Error Ly.Operand)
+ | RPostFilter (Either Ly.Error Ly.PostFilterFn)
| RMatcherSelect Ly.MatcherFactory
| RCaseSelect M.CaseSensitive
| ROperator (X.Token L.Posting)
- | RSortSpec (Ex.Exceptional Error Orderer)
+ | RSortSpec (Either Error Orderer)
| RColorToFile ColorToFile
| RScheme E.Changers
| RExprDesc X.ExprDesc
@@ -174,7 +172,7 @@ data OptResult
getPostFilters
:: [OptResult]
- -> Ex.Exceptional Ly.Error [Ly.PostFilterFn]
+ -> Either Ly.Error [Ly.PostFilterFn]
getPostFilters =
sequence
. mapMaybe f
@@ -197,7 +195,7 @@ getExprDesc df os = case mapMaybe f os of
getSortSpec
:: Orderer
-> [OptResult]
- -> Ex.Exceptional Error Orderer
+ -> Either Error Orderer
getSortSpec i ls =
let getSpec o = case o of
RSortSpec x -> Just x
@@ -208,12 +206,12 @@ getSortSpec i ls =
else fmap mconcat . sequence $ exSpecs
type Factory = M.CaseSensitive
- -> Text -> Ex.Exceptional Text M.Matcher
+ -> Text -> Either Text M.Matcher
makeToken
:: OptResult
-> St.State (M.CaseSensitive, Factory)
- (Maybe (Ex.Exceptional Ly.Error (X.Token L.Posting)))
+ (Maybe (Either Ly.Error (X.Token L.Posting)))
makeToken o = case o of
ROperand f -> do
(s, fty) <- St.get
@@ -234,15 +232,14 @@ makeToken o = case o of
makeTokens
:: Defaults
-> [OptResult]
- -> Ex.Exceptional Ly.Error ( [X.Token L.Posting]
+ -> Either Ly.Error ( [X.Token L.Posting]
, (M.CaseSensitive, Factory) )
makeTokens df os =
let initSt = (sensitive df, fty)
fty = case matcher df of
Within -> \c t -> return (M.within c t)
Exact -> \c t -> return (M.exact c t)
- TDFA -> M.tdfa
- PCRE -> M.pcre
+ PCRE -> \c t -> M.pcre c t
lsSt = mapM makeToken os
(ls, st') = St.runState lsSt initSt
in fmap (\xs -> (xs, st')) . sequence . catMaybes $ ls
@@ -344,20 +341,20 @@ processGlobal
-> Defaults
-> [I.Report]
-> [OptResult]
- -> Ex.Exceptional String
+ -> Either String
(Either a [MA.Mode (MA.ProgName -> String) (IO ())])
processGlobal rt srt df rpts os
= case processFiltOpts srt df os of
- Ex.Exception s -> Ex.throw s
- Ex.Success fo ->
+ Left s -> Left s
+ Right fo ->
return . Right $ map (makeMode (formatQty df) rt fo) rpts
processFiltOpts
:: Orderer
-> Defaults
-> [OptResult]
- -> Ex.Exceptional String FilterOpts
-processFiltOpts ord df os = Ex.mapException unpack $ do
+ -> Either String FilterOpts
+processFiltOpts ord df os = either (Left . unpack) Right $ do
postFilts <- getPostFilters os
sortSpec <- getSortSpec ord os
(toks, (rs, rf)) <- makeTokens df os
@@ -384,7 +381,7 @@ makeMode mkFmt rt fo r = fmap makeIO mode
(foExprDesc fo) (fmap snd (foSorterFilterer fo))
makeIO parseResult = do
(posArgs, printRpt) <-
- Ex.switch handleTextError return parseResult
+ either handleTextError return parseResult
items <- C.open posArgs
let fmt = mkFmt items
(txns, pps) = splitLedger items
@@ -395,7 +392,7 @@ makeMode mkFmt rt fo r = fmap makeIO mode
verbFiltChunks = (fst . foSorterFilterer fo $ txns) fmt
showFilterExpression printer (foShowExpression fo) (foPredicate fo)
showVerboseFilter printer (foVerboseFilter fo) verbFiltChunks
- Ex.switch handleTextError (R.putChunks term)
+ either handleTextError (R.putChunks term)
$ printRpt fmt txns pps
@@ -517,14 +514,14 @@ argMatch s1 s2 = case (s1, s2) of
(x == y) && ((map toUpper xs) `isPrefixOf` (map toUpper ys))
_ -> True
-sortSpecs :: MA.OptSpec (Ex.Exceptional Error Orderer)
+sortSpecs :: MA.OptSpec (Either Error Orderer)
sortSpecs = MA.OptSpec ["sort"] ['s'] (MA.OneArg f)
where
f a =
let matches = filter (\p -> a `argMatch` (fst p)) ords
in case matches of
x:[] -> return $ snd x
- _ -> Ex.throw $ "bad sort specification: " <> pack a <> "\n"
+ _ -> Left $ "bad sort specification: " <> pack a <> "\n"
@@ -642,10 +639,6 @@ help d pn = unlines $
, " Use \"pcre\" matcher"
++ ifDefault (matcher d == PCRE)
- , "--posix"
- , " Use \"posix\" matcher"
- ++ ifDefault (matcher d == TDFA)
-
, "-x, --exact"
, " Use \"exact\" matcher"
++ ifDefault (matcher d == Exact)
diff --git a/penny.cabal b/penny.cabal
index 33ed60b..636d05f 100644
--- a/penny.cabal
+++ b/penny.cabal
@@ -1,5 +1,5 @@
Name: penny
-Version: 0.26.0.0
+Version: 0.28.0.0
Cabal-version: >=1.8
Build-Type: Simple
License: BSD3
@@ -183,17 +183,15 @@ Library
Build-depends:
base ==4.6.*
, action-permutations ==0.0.0.0
- , binary ==0.7.*
, bytestring ==0.10.*
, cereal ==0.3.*
, containers ==0.5.*
- , explicit-exception ==0.1.*
- , matchers ==0.6.*
- , multiarg ==0.18.*
- , ofx ==0.2.*
+ , matchers ==0.10.*
+ , multiarg ==0.22.*
+ , ofx ==0.4.*
, old-locale ==1.0.*
, parsec >= 3.1.2 && < 3.2
- , prednote == 0.14.*
+ , prednote == 0.16.*
, pretty-show ==1.5.*
, rainbow ==0.4.*
, semigroups ==0.9.*
@@ -309,12 +307,12 @@ Executable penny-selloff
Build-depends:
penny
, base == 4.6.*
- , explicit-exception ==0.1.*
, containers ==0.5.*
+ , either ==3.4.*
, semigroups ==0.9.*
, text ==0.11.*
, parsec ==3.1.*
- , multiarg ==0.18.*
+ , multiarg ==0.22.*
, transformers ==0.3.*
other-modules: Paths_penny
@@ -336,8 +334,7 @@ Executable penny-diff
penny
, base ==4.6.*
, text ==0.11.*
- , multiarg ==0.18.*
- , explicit-exception == 0.1.*
+ , multiarg ==0.22.*
hs-source-dirs: bin
Main-is: penny-diff.hs
@@ -357,7 +354,7 @@ Executable penny-reprint
Build-depends:
penny
, base ==4.6.*
- , multiarg ==0.18.*
+ , multiarg ==0.22.*
, pretty-show ==1.5.*
, text ==0.11.*
@@ -377,8 +374,7 @@ Executable penny-reconcile
penny
, base ==4.6.*
, text ==0.11.*
- , multiarg ==0.18.*
- , explicit-exception ==0.1.*
+ , multiarg ==0.22.*
hs-source-dirs: bin
main-is: penny-reconcile.hs
@@ -423,8 +419,7 @@ Executable penny-test
, random-shuffle ==0.0.4
, base ==4.6.*
- , explicit-exception ==0.1.*
- , multiarg ==0.18.*
+ , multiarg ==0.22.*
, parsec >= 3.1.2 && < 3.2
, semigroups ==0.9.*
, text ==0.11.*
@@ -451,8 +446,7 @@ Executable penny-gibberish
, random ==1.0.*
, base ==4.6.*
- , explicit-exception ==0.1.*
- , multiarg ==0.18.*
+ , multiarg ==0.22.*
, semigroups ==0.9.*
, text ==0.11.*
, time ==1.4.*
diff --git a/tests/penny-gibberish.hs b/tests/penny-gibberish.hs
index 4b2105b..09f2b4c 100644
--- a/tests/penny-gibberish.hs
+++ b/tests/penny-gibberish.hs
@@ -1,7 +1,6 @@
module Main where
import qualified System.Console.MultiArg as MA
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified Test.QuickCheck.Gen as G
import qualified System.Random as Rand
import Control.Monad (replicateM)
@@ -38,18 +37,18 @@ options =
[ MA.OptSpec ["size"] "s" . MA.OneArgE $ \s -> do
i <- MA.reader s
if i < 1
- then Ex.throw (MA.ErrorMsg "non-positive size parameter")
+ then Left (MA.ErrorMsg "non-positive size parameter")
else return (\os -> os { optSize = i })
, MA.OptSpec ["count"] "c" . MA.OneArgE $ \s -> do
i <- MA.reader s
if i < 1
- then Ex.throw (MA.ErrorMsg "non-positive count parameter")
+ then Left (MA.ErrorMsg "non-positive count parameter")
else return (\os -> os { optCount = i })
]
-posArg :: a -> Ex.Exceptional MA.InputError b
-posArg _ = Ex.throw (MA.ErrorMsg "no non-option arguments accepted")
+posArg :: a -> Either MA.InputError b
+posArg _ = Left (MA.ErrorMsg "no non-option arguments accepted")
parse :: [(Opts -> Opts)] -> Opts
parse os = foldl (flip (.)) id os defaultOpts
diff --git a/tests/penny-test.hs b/tests/penny-test.hs
index 72859f5..ae808b4 100644
--- a/tests/penny-test.hs
+++ b/tests/penny-test.hs
@@ -2,7 +2,6 @@ module Main where
import qualified Lincoln as L
import qualified Copper as C
-import qualified Control.Monad.Exception.Synchronous as Ex
import qualified System.Console.MultiArg as MA
import qualified System.Exit as Exit
import qualified Test.QuickCheck as Q
@@ -36,7 +35,7 @@ main :: IO ()
main = do
opts <- MA.simpleHelp help options
MA.Intersperse
- ( const . Ex.Exception . MA.ErrorMsg
+ ( const . Left . MA.ErrorMsg
$ "this command does not accept positional arguments")
let args = foldl (flip (.)) id opts Q.stdArgs
runner = Q.quickCheckWithResult args