Constraints on definition of `length` should be strengthened
Ben Franksen
ben.franksen at online.de
Sat Apr 8 23:05:58 UTC 2017
Am 06.04.2017 um 21:18 schrieb amindfv at gmail.com:
>>> On 6 April 2017 at 23:56, <amindfv at gmail.com> wrote: I don't
>>> totally understand this viewpoint. It sounds like what you're
>>> saying is it's unfortunate that tuples (and everything else) are
>>> biased in Haskell, but because they are we're obligated to make
>>> all the legal instances we can for them.
>>>
>>> E.g. if I define a datatype "data Foo x y z", I'm powerless and
>>> sort of obligated to define "instance Functor (Foo x y)" if
>>> there's a legal one, regardless of if that's what I want Foo to
>>> mean.
>>
>> Is Foo going to be widely used or only an internal data type to
>> your own code?
>>
>
> For the sake of comparison, let's say it's going to be widely used.
> It's also a structure which isn't (conceptually) biased.
>
> If we're starting from a place of feeling that it's a shame Haskell
> is unable to have unbiased structures, then probably an "if we knew
> then what we know now" version of Haskell would have them. So then
> why knowingly create instances we think a "better Haskell" wouldn't
> have?
>
> Is the argument that if it's public-facing, someone's going to define
> the instance and so we should do it canonically? If so, this feels to
> me a little like "you can't fire me, I quit!" - doing what we don't
> want before someone else has a chance to.
I think the situation is analogous to honoring class laws. There is no
way in Haskell to enforce them. But there is an unwritten code of
conduct (sic!) for library writers, to define only (public) instances
that adhere to the stated laws. Why can't we not state that a certain
data type is intended to by symmetric in its arguments? And expect that
others respect that intent and refrain from defining asymmetric Functor,
Foldable, etc instances for it?
Cheers
Ben
More information about the Libraries
mailing list