  We exploit a large, complete optical diameter and HI flux limited sample of
spiral galaxies with types later than S0a to derive a robust measurement of the
HI mass function (HIMF) for masses log(M_HI/M_Sun) > 7.4 which takes into
account the effects of local large scale structure. The global HIMF derived for
this optically-selected sample is well fit by a Schechter function with alpha =
-1.24, log(M* / M_Sun)=9.99, phi* = 3.2 (10^{-3}) Mpc^{-3}. These values match
those derived from blind HI surveys to within the estimated uncertainties, yet
our estimated HIMF is clearly lower than most other estimates at the lowest
masses. We also investigate the variation in the derived HIMF among spiral
subclasses, finding a clear distinction between the Schechter parameters found
for types Sa-Sc and those Scd and later, in the sense that the HIMF of the
latest types is rising at the low mass end, whereas that of the main spiral
classes is flat or even declining. We also explore the possible environmental
dependence of the HIMF by computing it separately in regimes of differing
cosmic density. The HIMFs of higher density regions are found to have flatter
low-mass ends and lower values of M* than those of lower density regions,
although the statistical significance of the difference is low. We find that
the environmental dependence cannot be accounted for by morphological
segregation, and must be a consequence of differences among galaxies of the
same morphological type but found in different environments. If this dependence
is caused by the well known deficiency of galaxies in clusters, then it would
suggest that galaxies of small linear optical diameter are characterized by
higher HI deficiency, an expectation consistent with gas removal mechanisms
such as ram pressure stripping.
