[Haskell-cafe] Any precedent or plan for guaranteed-safe Eq and Ord instances?

adam vogt vogt.adam
Mon Oct 7 02:31:24 UTC 2013


On Sun, Oct 6, 2013 at 6:54 PM, Tillmann Rendel
<rendel at informatik.uni-marburg.de> wrote:
> Hi,
>
>
> Ryan Newton wrote:
>>
>> It is very hard for me to
>> see why people should be able to make their own Generic instances (that
>> might lie about the structure of the type), in Safe-Haskell.
>
>
> I guess that lying Generics instances might arise because of software
> evolution. Let's say we start with an abstract data type of binary trees.

Hi,

A real example exists in containers for the older Data class.
Data.Sequence.Seq pretends it is a list instead of a tree:

>>> gshow (S.fromList [1,2,3] S.|> 4)
"(<| (1) (<| (2) (<| (3) (<| (4) (empty)))))"

If there was a Generic instance for Seq, it would probably pretend to
be a list for the same reasons the Data instance is that way.

--
Adam




More information about the Haskell-Cafe mailing list