In Scheme, the primitive eq?
tests whether its arguments are the same object. For example, in the following list
(define lst
(let (x (list \'a
There is reallyUnsafePtrEquality#. Also see here
There's lots of approaches.
Eq
and Ord
instances regardless of the contained type.reallyUnsafePtrEquality#
but you should understand what's really unsafe about it before you use it!See also this answer about avoiding equality checks altogether.
It is not possible in Haskell, the pure language.
But in its implementation in GHC, there are loopholes, such as
In any case, using this in regular code would be very unidiomatic; at most I could imagine that building a highly specialized library for something (memoizatoin, hash tables, whatever) that then provides a sane, pure API, might be acceptable.