Author: Ben Franksen <firstname.lastname@example.org>
Date: Thu Sep 28 20:17:26 CEST 2017
* make type Repository abstract
We no longer export the data constructor and instead add a number of
accessor functions and one convenience wrapper (withRepoLocation). Renamed
the existing accessor function extractCache to repoCache for consistency.
Also added witness coercion functions and a single function to construct a
new Repository that is used only in D.R.Identify and D.R.Clone.
Despite the large number of changes in this patch, it is completely
harmless. It consists mostly of mechanical fixes everywhere we
pattern-matched on the Repo data constructor before.
I should, perhaps, remark on why I did this.
One reason is that this way of using pattern matching for the arguments
of top-level functions is abusive, IMO. It expresses a preference to
give a name to /things/, whereas the major strength of functional
programming is to give names to (small, re-usable) /functions/.
And, of course, there are the usual reasons: we can now add or remove
data members from Repository without having to change all functions that
take it as argument.
Last not least: we used pattern matching for two completely separate
reasons: (1) to get at (some of) the members and (2) to reconstruct an
identical copy with a different type, i.e. with "new" witnesses. These
two motives are now expressed with separate functions, making the
I agree that things are much cleaner with this patch, and your arguments
supporting the changes.
I like the new withRepoLocation function.
The introduction of coerceT/coerceU and such are useful, it avoids
artificially building another Repo from an existing one just to make the
One minor thing I would nitpick is the name repoHasPristine in place of
repoPristine (in the code, the situation of not having a pristine is
represented by a NoPristine pristine).
I do not like the name repoHasPristine either, but repoPristine sounded
too much like it returns the pristine tree for me, when in fact it just
returns an enumeration describing what kind of pristine we have.
Perhaps rename data Pristine to data PristineType, then rename
repoHasPristine to repoPristineType?