ENH kinda finalize shadow match rules

This commit is contained in:
Nathan Dwarshuis 2023-02-25 22:56:23 -05:00
parent 048872253f
commit ae3109a4ba
4 changed files with 15 additions and 6 deletions

View File

@ -4,7 +4,7 @@ let List/map =
let T = let T =
./Types.dhall ./Types.dhall
sha256:381b63c7dc210ab55f61a4ff6198fcd5d3922ba587b19dbd8e0834f269f05e13 sha256:3c6121710cb1d4ed84d9cb7ab6589fdcea79d1e4e07b33b22bd84e52506ea80f
let nullSplit = let nullSplit =
\(a : T.SplitAcnt) -> \(a : T.SplitAcnt) ->

View File

@ -442,7 +442,7 @@ checkAcntTypes ts i f = (go =<<) <$> lookupAccountType i
where where
go t go t
| t `L.elem` ts = Right $ f i | t `L.elem` ts = Right $ f i
| otherwise = Left $ AccountError i t | otherwise = Left $ AccountError i ts
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- statements -- statements

View File

@ -12,6 +12,7 @@ import Dhall.TH
import Language.Haskell.TH.Syntax (Lift) import Language.Haskell.TH.Syntax (Lift)
import RIO import RIO
import qualified RIO.Map as M import qualified RIO.Map as M
import qualified RIO.NonEmpty as NE
import qualified RIO.Text as T import qualified RIO.Text as T
import RIO.Time import RIO.Time
import Text.Regex.TDFA import Text.Regex.TDFA
@ -53,7 +54,7 @@ makeHaskellTypesWith
, SingleConstructor "Income" "Income" "(./dhall/Types.dhall).Income" , SingleConstructor "Income" "Income" "(./dhall/Types.dhall).Income"
, SingleConstructor "Budget" "Budget" "(./dhall/Types.dhall).Budget" , SingleConstructor "Budget" "Budget" "(./dhall/Types.dhall).Budget"
, SingleConstructor "Transfer" "Transfer" "(./dhall/Types.dhall).Transfer" , SingleConstructor "Transfer" "Transfer" "(./dhall/Types.dhall).Transfer"
, SingleConstructor "ShadowMatch" "ShadowMatch" "(./dhall/Types.dhall).ShadowMatch" , SingleConstructor "ShadowMatch" "ShadowMatch" "(./dhall/Types.dhall).ShadowMatch.Type"
, SingleConstructor "ShadowTransfer" "ShadowTransfer" "(./dhall/Types.dhall).ShadowTransfer" , SingleConstructor "ShadowTransfer" "ShadowTransfer" "(./dhall/Types.dhall).ShadowTransfer"
] ]
@ -597,7 +598,7 @@ data PatternSuberr = ZeroLength | ZeroRepeats deriving (Show)
data InsertError data InsertError
= RegexError !T.Text = RegexError !T.Text
| MatchValPrecisionError !Natural !Natural | MatchValPrecisionError !Natural !Natural
| AccountError !AcntID !AcntType | AccountError !AcntID !(NE.NonEmpty AcntType)
| InsertIOError !T.Text | InsertIOError !T.Text
| ParseError !T.Text | ParseError !T.Text
| ConversionError !T.Text | ConversionError !T.Text

View File

@ -43,6 +43,7 @@ import Internal.Types
import RIO import RIO
import qualified RIO.List as L import qualified RIO.List as L
import qualified RIO.Map as M import qualified RIO.Map as M
import qualified RIO.NonEmpty as NE
import qualified RIO.Text as T import qualified RIO.Text as T
import RIO.Time import RIO.Time
import Text.Regex.TDFA import Text.Regex.TDFA
@ -319,8 +320,15 @@ showError other = (: []) $ case other of
where where
showGreg (Just g) = showGregorian_ g showGreg (Just g) = showGregorian_ g
showGreg Nothing = "Inf" showGreg Nothing = "Inf"
-- TODO define (AccountError a ts) ->
(AccountError _ _) -> undefined T.unwords
[ "account type of key"
, singleQuote a
, "is not one of:"
, ts_
]
where
ts_ = T.intercalate ", " $ NE.toList $ fmap atName ts
(PatternError s b r p) -> T.unwords [msg, "in pattern: ", pat] (PatternError s b r p) -> T.unwords [msg, "in pattern: ", pat]
where where
pat = pat =