diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,9 +1,11 @@
 Internal/api/developer-ish changes in the hledger-lib (and hledger) packages.
 For user-visible changes, see the hledger package changelog.
 
-# 1.16.1 2019-12-03
+# 1.16.2 2020-01-14
 
+- add support for megaparsec 8 (#1175)
 
+# 1.16.1 2019-12-03
 
 - Drop unnecessary mtl-compat dependency
 
diff --git a/Text/Megaparsec/Custom.hs b/Text/Megaparsec/Custom.hs
--- a/Text/Megaparsec/Custom.hs
+++ b/Text/Megaparsec/Custom.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-} -- new
 {-# LANGUAGE LambdaCase #-}
@@ -176,7 +177,12 @@
     Left errBundle -> customFailure $ ErrorReparsing $ bundleErrors errBundle
 
   where
-    offsetInitialState :: Int -> s -> State s
+    offsetInitialState :: Int -> s ->
+#if MIN_VERSION_megaparsec(8,0,0)
+      State s e
+#else
+      State s
+#endif
     offsetInitialState initialOffset s = State
       { stateInput  = s
       , stateOffset = initialOffset
@@ -187,6 +193,9 @@
         , pstateTabWidth = defaultTabWidth
         , pstateLinePrefix = ""
         }
+#if MIN_VERSION_megaparsec(8,0,0)
+      , stateParseErrors = []
+#endif
       }
 
 --- * Pretty-printing custom parse errors
diff --git a/hledger-lib.cabal b/hledger-lib.cabal
--- a/hledger-lib.cabal
+++ b/hledger-lib.cabal
@@ -4,10 +4,10 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: f67238ad457aa23ba68686a932bc3f37f30d6f3f9f4514468e35e960ab81fe1b
+-- hash: eff7cc5cd5bf68cfdad1cc47374767d072f03ed6de99dfbd286885788a26dbab
 
 name:           hledger-lib
-version:        1.16.1
+version:        1.16.2
 synopsis:       Core data types, parsers and functionality for the hledger accounting tools
 description:    This is a reusable library containing hledger's core functionality.
                 .
@@ -126,7 +126,7 @@
     , file-embed >=0.0.10
     , filepath
     , hashtables >=1.2.3.1
-    , megaparsec >=7.0.0 && <8
+    , megaparsec >=7.0.0 && <8.1
     , mtl >=2.2.1
     , old-time
     , parsec >=3
@@ -177,7 +177,7 @@
     , file-embed >=0.0.10
     , filepath
     , hashtables >=1.2.3.1
-    , megaparsec >=7.0.0 && <8
+    , megaparsec >=7.0.0 && <8.1
     , mtl >=2.2.1
     , old-time
     , parsec >=3
@@ -231,7 +231,7 @@
     , filepath
     , hashtables >=1.2.3.1
     , hledger-lib
-    , megaparsec >=7.0.0 && <8
+    , megaparsec >=7.0.0 && <8.1
     , mtl >=2.2.1
     , old-time
     , parsec >=3
diff --git a/hledger_csv.5 b/hledger_csv.5
--- a/hledger_csv.5
+++ b/hledger_csv.5
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger_csv" "5" "December 2019" "hledger 1.16.1" "hledger User Manuals"
+.TH "hledger_csv" "5" "January 2020" "hledger 1.16.2" "hledger User Manuals"
 
 
 
@@ -508,6 +508,7 @@
 .PP
 \f[C]balanceN\f[R] sets a balance assertion amount (or if the posting
 amount is left empty, a balance assignment).
+You may need to adjust this with the \f[C]balance-type\f[R] rule.
 .PP
 Finally, \f[C]commentN\f[R] sets a comment on the Nth posting.
 Comments can also contain tags, as usual.
@@ -731,6 +732,34 @@
 
 ## common rules
 include categorisation.rules
+\f[R]
+.fi
+.SS \f[C]balance-type\f[R]
+.PP
+Balance assertions generated by assigning to balanceN are of the simple
+\f[C]=\f[R] type by default, which is a single-commodity,
+subaccount-excluding assertion.
+You may find the subaccount-including variants more useful, eg if you
+have created some virtual subaccounts of checking to help with
+budgeting.
+You can select a different type of assertion with the
+\f[C]balance-type\f[R] rule:
+.IP
+.nf
+\f[C]
+# balance assertions will consider all commodities and all subaccounts
+balance-type ==*
+\f[R]
+.fi
+.PP
+Here are the balance assertion types for quick reference:
+.IP
+.nf
+\f[C]
+=    single commodity, exclude subaccounts
+=*   single commodity, include subaccounts
+==   multi commodity,  exclude subaccounts
+==*  multi commodity,  include subaccounts
 \f[R]
 .fi
 .SH TIPS
diff --git a/hledger_csv.info b/hledger_csv.info
--- a/hledger_csv.info
+++ b/hledger_csv.info
@@ -1,9 +1,9 @@
-This is hledger_csv.info, produced by makeinfo version 6.5 from stdin.
+This is hledger_csv.info, produced by makeinfo version 6.7 from stdin.
 
 
 File: hledger_csv.info,  Node: Top,  Next: EXAMPLES,  Up: (dir)
 
-hledger_csv(5) hledger 1.16.1
+hledger_csv(5) hledger 1.16.2
 *****************************
 
 hledger can read CSV (comma-separated value, or character-separated
@@ -376,6 +376,7 @@
 * date-format::
 * newest-first::
 * include::
+* balance-type::
 
 
 File: hledger_csv.info,  Node: skip,  Next: fields,  Up: CSV RULES
@@ -466,7 +467,8 @@
 affects ALL postings.
 
    'balanceN' sets a balance assertion amount (or if the posting amount
-is left empty, a balance assignment).
+is left empty, a balance assignment).  You may need to adjust this with
+the 'balance-type' rule.
 
    Finally, 'commentN' sets a comment on the Nth posting.  Comments can
 also contain tags, as usual.
@@ -625,7 +627,7 @@
 newest-first
 
 
-File: hledger_csv.info,  Node: include,  Prev: newest-first,  Up: CSV RULES
+File: hledger_csv.info,  Node: include,  Next: balance-type,  Prev: newest-first,  Up: CSV RULES
 
 2.8 'include'
 =============
@@ -648,6 +650,29 @@
 include categorisation.rules
 
 
+File: hledger_csv.info,  Node: balance-type,  Prev: include,  Up: CSV RULES
+
+2.9 'balance-type'
+==================
+
+Balance assertions generated by assigning to balanceN are of the simple
+'=' type by default, which is a single-commodity, subaccount-excluding
+assertion.  You may find the subaccount-including variants more useful,
+eg if you have created some virtual subaccounts of checking to help with
+budgeting.  You can select a different type of assertion with the
+'balance-type' rule:
+
+# balance assertions will consider all commodities and all subaccounts
+balance-type ==*
+
+   Here are the balance assertion types for quick reference:
+
+=    single commodity, exclude subaccounts
+=*   single commodity, include subaccounts
+==   multi commodity,  exclude subaccounts
+==*  multi commodity,  include subaccounts
+
+
 File: hledger_csv.info,  Node: TIPS,  Prev: CSV RULES,  Up: Top
 
 3 TIPS
@@ -900,45 +925,52 @@
 Ref: #paypal6532
 Node: CSV RULES14415
 Ref: #csv-rules14524
-Node: skip14769
-Ref: #skip14862
-Node: fields15237
-Ref: #fields15359
-Node: Transaction field names16426
-Ref: #transaction-field-names16586
-Node: Posting field names16697
-Ref: #posting-field-names16849
-Node: field assignment18081
-Ref: #field-assignment18217
-Node: if19035
-Ref: #if19144
-Node: end20860
-Ref: #end20966
-Node: date-format21190
-Ref: #date-format21322
-Node: newest-first22071
-Ref: #newest-first22209
-Node: include22892
-Ref: #include23000
-Node: TIPS23444
-Ref: #tips23526
-Node: Valid CSV23775
-Ref: #valid-csv23894
-Node: Other separator characters24086
-Ref: #other-separator-characters24274
-Node: Reading multiple CSV files24603
-Ref: #reading-multiple-csv-files24800
-Node: Valid transactions25041
-Ref: #valid-transactions25219
-Node: Deduplicating importing25847
-Ref: #deduplicating-importing26026
-Node: Setting amounts27059
-Ref: #setting-amounts27228
-Node: Setting currency/commodity28214
-Ref: #setting-currencycommodity28406
-Node: Referencing other fields29209
-Ref: #referencing-other-fields29409
-Node: How CSV rules are evaluated30306
-Ref: #how-csv-rules-are-evaluated30477
+Node: skip14786
+Ref: #skip14879
+Node: fields15254
+Ref: #fields15376
+Node: Transaction field names16443
+Ref: #transaction-field-names16603
+Node: Posting field names16714
+Ref: #posting-field-names16866
+Node: field assignment18157
+Ref: #field-assignment18293
+Node: if19111
+Ref: #if19220
+Node: end20936
+Ref: #end21042
+Node: date-format21266
+Ref: #date-format21398
+Node: newest-first22147
+Ref: #newest-first22285
+Node: include22968
+Ref: #include23097
+Node: balance-type23541
+Ref: #balance-type23659
+Node: TIPS24359
+Ref: #tips24441
+Node: Valid CSV24690
+Ref: #valid-csv24809
+Node: Other separator characters25001
+Ref: #other-separator-characters25189
+Node: Reading multiple CSV files25518
+Ref: #reading-multiple-csv-files25715
+Node: Valid transactions25956
+Ref: #valid-transactions26134
+Node: Deduplicating importing26762
+Ref: #deduplicating-importing26941
+Node: Setting amounts27974
+Ref: #setting-amounts28143
+Node: Setting currency/commodity29129
+Ref: #setting-currencycommodity29321
+Node: Referencing other fields30124
+Ref: #referencing-other-fields30324
+Node: How CSV rules are evaluated31221
+Ref: #how-csv-rules-are-evaluated31392
 
 End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/hledger_csv.txt b/hledger_csv.txt
--- a/hledger_csv.txt
+++ b/hledger_csv.txt
@@ -396,7 +396,8 @@
        fects ALL postings.
 
        balanceN sets a balance assertion amount (or if the posting  amount  is
-       left empty, a balance assignment).
+       left  empty,  a  balance assignment).  You may need to adjust this with
+       the balance-type rule.
 
        Finally, commentN sets a comment on the Nth posting.  Comments can also
        contain tags, as usual.
@@ -406,11 +407,11 @@
    field assignment
               HLEDGERFIELDNAME FIELDVALUE
 
-       Instead of or in addition to a fields list, you can use  a  "field  as-
-       signment"  rule  to set the value of a single hledger field, by writing
-       its name (any of the standard hledger field names above) followed by  a
-       text  value.  The value may contain interpolated CSV fields, referenced
-       by their 1-based position in the CSV record (%N), or by the  name  they
+       Instead  of  or  in addition to a fields list, you can use a "field as-
+       signment" rule to set the value of a single hledger field,  by  writing
+       its  name (any of the standard hledger field names above) followed by a
+       text value.  The value may contain interpolated CSV fields,  referenced
+       by  their  1-based position in the CSV record (%N), or by the name they
        were given in the fields list (%CSVFIELDNAME).  Some examples:
 
               # set the amount to the 4th CSV field, with " USD" appended
@@ -419,7 +420,7 @@
               # combine three fields to make a comment, containing note: and date: tags
               comment note: %somefield - %anotherfield, date: %1
 
-       Interpolation  strips  outer  whitespace (so a CSV value like " 1 " be-
+       Interpolation strips outer whitespace (so a CSV value like "  1  "  be-
        comes 1 when interpolated) (#1051).  See TIPS below for more about ref-
        erencing other fields.
 
@@ -434,28 +435,28 @@
                RULE
                RULE
 
-       Conditional  blocks ("if blocks") are a block of rules that are applied
-       only to CSV records which match certain patterns.  They are often  used
+       Conditional blocks ("if blocks") are a block of rules that are  applied
+       only  to CSV records which match certain patterns.  They are often used
        for customising account names based on transaction descriptions.
 
        A single pattern can be written on the same line as the "if"; or multi-
        ple patterns can be written on the following lines, non-indented.  Mul-
-       tiple  patterns  are  OR'd  (any  one of them can match).  Patterns are
+       tiple patterns are OR'd (any one of  them  can  match).   Patterns  are
        case-insensitive regular expressions which try to match anywhere within
-       the  whole CSV record (POSIX extended regular expressions with some ad-
+       the whole CSV record (POSIX extended regular expressions with some  ad-
        ditions,   see   https://hledger.org/hledger.html#regular-expressions).
        Note the CSV record they see is close to, but not identical to, the one
        in the CSV file; enclosing double quotes will be removed, and the sepa-
        rator character is always comma.
 
-       It's  not  yet easy to match within a specific field.  If the data does
+       It's not yet easy to match within a specific field.  If the  data  does
        not contain commas, you can hack it with a regular expression like:
 
               # match "foo" in the fourth field
               if ^([^,]*,){3}foo
 
-       After the patterns there should be one or more rules to apply, all  in-
-       dented  by at least one space.  Three kinds of rule are allowed in con-
+       After  the patterns there should be one or more rules to apply, all in-
+       dented by at least one space.  Three kinds of rule are allowed in  con-
        ditional blocks:
 
        o field assignments (to set a hledger field)
@@ -479,7 +480,7 @@
                comment  XXX deductible ? check it
 
    end
-       This rule can be used inside if blocks (only),  to  make  hledger  stop
+       This  rule  can  be  used inside if blocks (only), to make hledger stop
        reading this CSV file and move on to the next input file, or to command
        execution.  Eg:
 
@@ -490,10 +491,10 @@
    date-format
               date-format DATEFMT
 
-       This is a helper for the date (and date2) fields.  If  your  CSV  dates
-       are  not  formatted  like  YYYY-MM-DD, YYYY/MM/DD or YYYY.MM.DD, you'll
-       need to add a date-format rule describing them  with  a  strptime  date
-       parsing  pattern, which must parse the CSV date value completely.  Some
+       This  is  a  helper for the date (and date2) fields.  If your CSV dates
+       are not formatted like YYYY-MM-DD,  YYYY/MM/DD  or  YYYY.MM.DD,  you'll
+       need  to  add  a  date-format rule describing them with a strptime date
+       parsing pattern, which must parse the CSV date value completely.   Some
        examples:
 
               # MM/DD/YY
@@ -515,15 +516,15 @@
        mat.html#v:formatTime
 
    newest-first
-       hledger  always sorts the generated transactions by date.  Transactions
-       on the same date should appear in the same order as their CSV  records,
-       as  hledger  can  usually auto-detect whether the CSV's normal order is
+       hledger always sorts the generated transactions by date.   Transactions
+       on  the same date should appear in the same order as their CSV records,
+       as hledger can usually auto-detect whether the CSV's  normal  order  is
        oldest first or newest first.  But if all of the following are true:
 
-       o the CSV might sometimes contain just one day  of  data  (all  records
+       o the  CSV  might  sometimes  contain just one day of data (all records
          having the same date)
 
-       o the  CSV  records are normally in reverse chronological order (newest
+       o the CSV records are normally in reverse chronological  order  (newest
          at the top)
 
        o and you care about preserving the order of same-day transactions
@@ -536,9 +537,9 @@
    include
               include RULESFILE
 
-       This includes the contents of another CSV rules  file  at  this  point.
-       RULESFILE  is  an  absolute file path or a path relative to the current
-       file's directory.  This can be useful for sharing common rules  between
+       This  includes  the  contents  of another CSV rules file at this point.
+       RULESFILE is an absolute file path or a path relative  to  the  current
+       file's  directory.  This can be useful for sharing common rules between
        several rules files, eg:
 
               # someaccount.csv.rules
@@ -551,6 +552,24 @@
               ## common rules
               include categorisation.rules
 
+   balance-type
+       Balance assertions generated by assigning to balanceN are of the simple
+       =  type  by  default, which is a single-commodity, subaccount-excluding
+       assertion.  You may find the subaccount-including variants more useful,
+       eg  if  you  have  created some virtual subaccounts of checking to help
+       with budgeting.  You can select a different type of assertion with  the
+       balance-type rule:
+
+              # balance assertions will consider all commodities and all subaccounts
+              balance-type ==*
+
+       Here are the balance assertion types for quick reference:
+
+              =    single commodity, exclude subaccounts
+              =*   single commodity, include subaccounts
+              ==   multi commodity,  exclude subaccounts
+              ==*  multi commodity,  include subaccounts
+
 TIPS
    Valid CSV
        hledger  accepts  CSV  conforming to RFC 4180.  When CSV values are en-
@@ -760,4 +779,4 @@
 
 
 
-hledger 1.16.1                   December 2019                  hledger_csv(5)
+hledger 1.16.2                   January 2020                   hledger_csv(5)
diff --git a/hledger_journal.5 b/hledger_journal.5
--- a/hledger_journal.5
+++ b/hledger_journal.5
@@ -1,6 +1,6 @@
 .\"t
 
-.TH "hledger_journal" "5" "December 2019" "hledger 1.16.1" "hledger User Manuals"
+.TH "hledger_journal" "5" "January 2020" "hledger 1.16.2" "hledger User Manuals"
 
 
 
diff --git a/hledger_journal.info b/hledger_journal.info
--- a/hledger_journal.info
+++ b/hledger_journal.info
@@ -1,10 +1,10 @@
-This is hledger_journal.info, produced by makeinfo version 6.5 from
+This is hledger_journal.info, produced by makeinfo version 6.7 from
 stdin.
 
 
 File: hledger_journal.info,  Node: Top,  Next: FILE FORMAT,  Up: (dir)
 
-hledger_journal(5) hledger 1.16.1
+hledger_journal(5) hledger 1.16.2
 *********************************
 
 hledger's usual data source is a plain text file containing journal
@@ -1863,3 +1863,8 @@
 Ref: #editor-support63334
 
 End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/hledger_journal.txt b/hledger_journal.txt
--- a/hledger_journal.txt
+++ b/hledger_journal.txt
@@ -1414,4 +1414,4 @@
 
 
 
-hledger 1.16.1                   December 2019              hledger_journal(5)
+hledger 1.16.2                   January 2020               hledger_journal(5)
diff --git a/hledger_timeclock.5 b/hledger_timeclock.5
--- a/hledger_timeclock.5
+++ b/hledger_timeclock.5
@@ -1,5 +1,5 @@
 
-.TH "hledger_timeclock" "5" "December 2019" "hledger 1.16.1" "hledger User Manuals"
+.TH "hledger_timeclock" "5" "January 2020" "hledger 1.16.2" "hledger User Manuals"
 
 
 
@@ -63,7 +63,7 @@
 and perhaps the extras in ledgerutils.el
 .IP \[bu] 2
 at the command line, use these bash aliases:
-\f[C]shell   alias ti=\[dq]echo i \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] \[rs]$* >>$TIMELOG\[dq]   alias to=\[dq]echo o \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] >>$TIMELOG\[dq]\f[R]
+\f[C]shell     alias ti=\[dq]echo i \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] \[rs]$* >>$TIMELOG\[dq]     alias to=\[dq]echo o \[ga]date \[aq]+%Y-%m-%d %H:%M:%S\[aq]\[ga] >>$TIMELOG\[dq]\f[R]
 .IP \[bu] 2
 or use the old \f[C]ti\f[R] and \f[C]to\f[R] scripts in the ledger 2.x
 repository.
diff --git a/hledger_timeclock.info b/hledger_timeclock.info
--- a/hledger_timeclock.info
+++ b/hledger_timeclock.info
@@ -1,10 +1,10 @@
-This is hledger_timeclock.info, produced by makeinfo version 6.5 from
+This is hledger_timeclock.info, produced by makeinfo version 6.7 from
 stdin.
 
 
 File: hledger_timeclock.info,  Node: Top,  Up: (dir)
 
-hledger_timeclock(5) hledger 1.16.1
+hledger_timeclock(5) hledger 1.16.2
 ***********************************
 
 hledger can read timeclock files.  As with Ledger, these are (a subset
@@ -59,3 +59,8 @@
 Node: Top78
 
 End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/hledger_timeclock.txt b/hledger_timeclock.txt
--- a/hledger_timeclock.txt
+++ b/hledger_timeclock.txt
@@ -45,9 +45,9 @@
        o use  emacs  and the built-in timeclock.el, or the extended timeclock-
          x.el and perhaps the extras in ledgerutils.el
 
-       o at the command line, use these bash aliases: shell   alias ti="echo i
-         `date  '+%Y-%m-%d %H:%M:%S'` \$* >>$TIMELOG"   alias to="echo o `date
-         '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG"
+       o at the command line, use these bash aliases: shell     alias ti="echo
+         i  `date  '+%Y-%m-%d  %H:%M:%S'` \$* >>$TIMELOG"     alias to="echo o
+         `date '+%Y-%m-%d %H:%M:%S'` >>$TIMELOG"
 
        o or use the old ti and to scripts in the ledger 2.x repository.  These
          rely  on  a "timeclock" executable which I think is just the ledger 2
@@ -78,4 +78,4 @@
 
 
 
-hledger 1.16.1                   December 2019            hledger_timeclock(5)
+hledger 1.16.2                   January 2020             hledger_timeclock(5)
diff --git a/hledger_timedot.5 b/hledger_timedot.5
--- a/hledger_timedot.5
+++ b/hledger_timedot.5
@@ -1,5 +1,5 @@
 
-.TH "hledger_timedot" "5" "December 2019" "hledger 1.16.1" "hledger User Manuals"
+.TH "hledger_timedot" "5" "January 2020" "hledger 1.16.2" "hledger User Manuals"
 
 
 
diff --git a/hledger_timedot.info b/hledger_timedot.info
--- a/hledger_timedot.info
+++ b/hledger_timedot.info
@@ -1,10 +1,10 @@
-This is hledger_timedot.info, produced by makeinfo version 6.5 from
+This is hledger_timedot.info, produced by makeinfo version 6.7 from
 stdin.
 
 
 File: hledger_timedot.info,  Node: Top,  Next: FILE FORMAT,  Up: (dir)
 
-hledger_timedot(5) hledger 1.16.1
+hledger_timedot(5) hledger 1.16.2
 *********************************
 
 Timedot is a plain text format for logging dated, categorised quantities
@@ -115,3 +115,8 @@
 Ref: #file-format913
 
 End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
diff --git a/hledger_timedot.txt b/hledger_timedot.txt
--- a/hledger_timedot.txt
+++ b/hledger_timedot.txt
@@ -124,4 +124,4 @@
 
 
 
-hledger 1.16.1                   December 2019              hledger_timedot(5)
+hledger 1.16.2                   January 2020               hledger_timedot(5)
