RFC: Can DefaultSignature compile-time conditional APIs be regarded "benign"?

Roman Cheplyaka roma at ro-che.info
Mon Nov 12 10:44:22 CET 2012

* José Pedro Magalhães <jpm at cs.uu.nl> [2012-11-12 09:27:17+0000]
> Hi,
> I would prefer it if packages would use DefaultSignatures conditionally,
> instead of creating new packages just to define a generic variant of a
> function. In general, though, I think it's good practice to define the
> defaults as separate functions (like `genericSize`) and export them, so
> that those not using DefaultSignatures can still write an instance easily.

Do you propose exposing genericSize conditionally?

I'm strongly against this. I think that packages' interfaces may not
depend on the compiler or compilation options. Only the implementation
of the intreface may.

> As for the concerns about people using DefaultSignatures and not realizing
> their code is not portable, I guess we could reject programs that use a
> default signature (when writing an empty instance) unless they enable
> -XDefaultSignatures. Then people would know they are relying on an
> extension.

Can't we simply ignore default signatures (and corresponding default
definitions) when DefaultSignatures is off?


  instance Show Foo

is accepted in any case, but has different semantics depending on
whether DefaultSignatures is on. This way it's more Haskell2010

I realise that changing semantics is not very good, but people usually
test this kind of code anyway, so I don't think it will be a big
problem in practice.

In that case it'd make sense to add a separate flag
(-XUseGenericDefinition?) whose impact on the program semantics is more
obvious from its name.


More information about the Libraries mailing list