Skip to content

Commit

Permalink
Correct logic when to orphan Hashable ByteArray (#2460)
Browse files Browse the repository at this point in the history
PR #2448 and #2449 were incomplete, missing some cases where we still
needed to create an orphan instance for `Hashable ByteArray` ourselves.
This should get it right, including for when we will support GHC 9.4
(which is guarded by the expression `MIN_VERSION_base(4,17,0)`).

Fixes #2453
  • Loading branch information
DigitalBrains1 committed Apr 28, 2023
1 parent da1746a commit c56131d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions clash-lib/src/Data/Primitive/ByteArray/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ import GHC.Exts (IsList(..))
import Control.DeepSeq (NFData(..))
#endif

#if !MIN_VERSION_hashable(1,4,1)
-- Hashable <1.4.1 doesn't define hashable instances at all
-- hashable 1.4.2 defines Hashable for Data.Array.Byte.ByteArray, either from
-- base or from the data-array-byte compat package for GHC < 9.4.
-- primitive 0.8.0.0 re-exports this ByteArray.
#if !MIN_VERSION_primitive(0,8,0)
-- In primitive < 0.8.0.0, its ByteArray is a distinct type from
-- Data.Array.Byte.ByteArray (insofar as the latter even exists).
#define DEFINE_HASHABLE_BYTEARRAY
#elif !MIN_VERSION_hashable(1,4,1)
-- hashable < 1.4.1 doesn't define a Hashable ByteArray instance at all.
#define DEFINE_HASHABLE_BYTEARRAY
#elif !MIN_VERSION_hashable(1,4,2)
-- Hashable 1.4.1 defines hashable for _some_ base versions
-- hashable 1.4.1 defines hashable for the ByteArray added to base 4.17.
#if !MIN_VERSION_base(4,17,0)
#define DEFINE_HASHABLE_BYTEARRAY
#endif
Expand Down

0 comments on commit c56131d

Please sign in to comment.