не такой же, а тот же самый объект
Пока думаю использовать декартово произведение на Data.Unique, но это усложняет апи и вообще требует IO.
Общая задача - пессимистичное сравнение объектов произвольного типа (т.е. если равенство возвращает True то точно одинаковые, а если False то неизвестно)
https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-Exts.html#v:reallyUnsafePtrEquality
Спасибо! То что нужно
но я не знаю, почему оно really unsafe
reallyUnsafePtrEquality# :: a -> a -> Int# Source
{- Note [Pointer equality operations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Many primitive types - such as Array#, ByteArray#, MVar#, ... - are boxed: they are represented by pointers to the underlying data. It is thus possible to directly compare these pointers for equality, as opposed to comparing the underlying data that the pointers refer to (for instance, comparing two arrays element-wise). To do this, GHC provides the primop reallyUnsafePtrEquality#, which is both levity-polymorphic and heterogeneous. As its name indicates, it is an unsafe operation which can yield unpredictable results, as explained in Note [Pointer comparison operations] in primops.txt.pp For a more user-friendly interface, this module defines specialisations of the reallyUnsafePtrEquality# primop at various primitive types, such as Array#, ByteArray#, MVar#, ... -}
Обсуждают сегодня