ml at isaac.cedarswampstudios.org
Mon Jul 20 12:34:02 EDT 2009
is a confusing mess!
The most important module is named SrcLoc, which is acceptable.
It contains three types,
SrcSpan, which approximately is two SrcLocs (begin and end),
and Located, which combines a SrcSpan (not a SrcLoc!) with an arbitrary
In practice (well, in my case at least) you almost always want a SrcSpan
and not a SrcLoc.
Many of the functions on SrcLoc have "srcLoc" in their names, which is good.
However, so do many of the functions on Located-and-SrcSpan, which is
terrible. It gets a little worse when you combine with the (fairly
sensibly named functions) at Name.NamedThing
noLoc, getLoc, addCLoc, combineLocs work on Locateds.
noSrcLoc, getSrcLoc, work on SrcLocs. Instead, noSrcSpan and getSrcSpan
are the ones you want.
Okay it's not quite as bad as I thought. You want to avoid a function
iff it contains the whole phrase "srcLoc". But I still got confused a
lot of times. I wonder if we could rename something so that SrcLoc and
Located don't have the same word-part in them, because they aren't
really closely enough related? Even if it's just renaming "SrcLoc" to
"SrcSpot" or something.
It's also annoying that Name.getSrcSpan doesn't work on Locateds
(inevitable I guess since it's type-different from NamedThing), but the
function you have to use instead is called getLoc, even though it also
produces a SrcSpan (only the argument-type is different). Hmm.
More information about the Cvs-ghc