+ close(OLDHIF) || &tidy_up_and_die(1,"Failed reading from $ifile\n");
+ close(NEWHIF) || &tidy_up_and_die(1,"Failed writing to $ofile\n");
+}
+\end{code}
+
+\begin{code}
+sub hiSectionsOnly {
+ local($ifile,$ofile) = @_;
+
+ open(OLDHIF, "< $ifile") || &tidy_up_and_die(1,"Can't open $ifile (read)\n");
+ open(NEWHIF, "> $ofile") || &tidy_up_and_die(1,"Can't open $ofile (write)\n");
+
+ # read up to _usages_ line
+ $_ = <OLDHIF>;
+ while ($_ ne '' ) {
+ if ( /^__export/ && $HiSection {'exports'} ||
+ /^import / && $HiSection {'imports'} ||
+ /^\d+ ([^ ]+ :: |type |data |class |newtype )/ && $HiSection {'declarations'} ||
+ /^instance / && $HiSection {'instances'} ) {
+ print NEWHIF $_;
+ $_ = <OLDHIF>;
+ } else {
+ $_ = <OLDHIF>;