Skip to content

Instantly share code, notes, and snippets.

@simonmichael simonmichael/a.hs
Last active Mar 1, 2019

Embed
What would you like to do?
strange non-exhaustive error with GHC 7
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
You can’t perform that action at this time.