SrcLoc/SrcSpan/Located naming
Isaac Dupree
ml at isaac.cedarswampstudios.org
Mon Jul 20 14:51:18 EDT 2009
Do we make any attempt to keep the GHC API consistent between major
releases, or is the policy generally just to make any naming changes
that we find fitting for GHC's purposes?
-Isaac
Thomas Schilling wrote:
> I think the inconsistencies are mostly because SrcSpan was added
> later. Patches to improve the problematic cases would (most likely)
> be welcome.
>
> 2009/7/20 Isaac Dupree <ml at isaac.cedarswampstudios.org>:
>> is a confusing mess!
>> The most important module is named SrcLoc, which is acceptable.
>> It contains three types,
>> SrcLoc,
>> SrcSpan, which approximately is two SrcLocs (begin and end),
>> and Located, which combines a SrcSpan (not a SrcLoc!) with an arbitrary
>> other type.
>>
>> 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.
>>
>> -Isaac
>>
>> _______________________________________________
>> Cvs-ghc mailing list
>> Cvs-ghc at haskell.org
>> http://www.haskell.org/mailman/listinfo/cvs-ghc
>>
>
>
>
More information about the Cvs-ghc
mailing list