-
-
Save simonmichael/5ed0ad2c76b2f3452d0c260343d0a542 to your computer and use it in GitHub Desktop.
strange non-exhaustive error with GHC 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addOrAssignAmountAndCheckAssertionB :: Posting -> Balancing s Posting | |
addOrAssignAmountAndCheckAssertionB p@Posting{paccount=acc, pamount=amt, pbalanceassertion=mba} -- line 730 | |
| hasAmount p = do | |
newbal <- addAmountB acc amt | |
whenM (R.reader bsAssrt) $ checkBalanceAssertionB p newbal | |
return p | |
| Nothing <- mba = return p | |
| Just BalanceAssertion{baamount,batotal} <- mba = do | |
(diff,newbal) <- case batotal of | |
True -> do | |
-- a total balance assignment | |
let newbal = Mixed [baamount] | |
diff <- setAmountB acc newbal | |
return (diff,newbal) | |
False -> do | |
-- a partial balance assignment | |
oldbalothercommodities <- filterMixedAmount ((acommodity baamount /=) . acommodity) <$> getAmountB acc | |
let assignedbalthiscommodity = Mixed [baamount] | |
newbal = oldbalothercommodities + assignedbalthiscommodity | |
diff <- setAmountB acc newbal | |
return (diff,newbal) | |
let p' = p{pamount=diff, poriginal=Just $ originalPosting p} | |
whenM (R.reader bsAssrt) $ checkBalanceAssertionB p' newbal | |
return p' | |
{- | |
GHC 7.10.3: | |
/home/simon/src/hledger/hledger-lib/Hledger/Data/Journal.hs:730:1: Warning: | |
Pattern match(es) are non-exhaustive | |
In an equation for ‘addOrAssignAmountAndCheckAssertionB’: | |
Patterns not matched: Posting _ _ _ _ _ _ _ _ _ _ _ | |
GHC 8+: ok | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment