[Haskell-cafe] Puzzling instance method definitions in Data.Sequence.Internal

Viktor Dukhovni ietf-dane at dukhovni.org
Tue Mar 2 08:16:04 UTC 2021


> On Mar 2, 2021, at 6:08 AM, Henning Thielemann <lemming at henning-thielemann.de> wrote:
> 
> On Tue, 2 Mar 2021, Viktor Dukhovni wrote:
> 
>> So the intent seems clear, but I don't understand how the instance method
>> definitions are valid.  The imports of Both Prelude and Data.Foldable don't
>> include `length` or `null`:
>> 
>>  https://github.com/haskell/containers/blob/master/containers/src/Data/Sequence/Internal.hs#L194-L213
> 
> It is enough if the method name is imported with qualification. Surprising and maybe inconsistent but that's the state of affairs. GHC even forbids qualification on the left-hand side of a method definition. This at least is consistent with all function definitions.

Thanks, that explains it.  By far from obvious, but handy to know.
Indeed the module also has (one more line than I took into account):

   https://github.com/haskell/containers/blob/master/containers/src/Data/Sequence/Internal.hs#L214

   import qualified Data.Foldable as F

Much appreciated.

-- 
	Viktor.



More information about the Haskell-Cafe mailing list