|
5 | 5 | {-# LANGUAGE PatternSynonyms #-}
|
6 | 6 | {-# LANGUAGE PolyKinds #-}
|
7 | 7 | {-# LANGUAGE ScopedTypeVariables #-}
|
| 8 | +{-# LANGUAGE TypeApplications #-} |
8 | 9 | {-# LANGUAGE TypeFamilies #-}
|
9 | 10 | {-# LANGUAGE TypeOperators #-}
|
10 | 11 |
|
@@ -418,12 +419,42 @@ instance Structured a => Structured (Ratio a) where structure = containerStructu
|
418 | 419 | instance Structured a => Structured [a] where structure = containerStructure
|
419 | 420 | instance Structured a => Structured (NonEmpty a) where structure = containerStructure
|
420 | 421 |
|
421 |
| -instance (Structured a1, Structured a2) => Structured (a1, a2) |
422 |
| -instance (Structured a1, Structured a2, Structured a3) => Structured (a1, a2, a3) |
423 |
| -instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (a1, a2, a3, a4) |
424 |
| -instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (a1, a2, a3, a4, a5) |
425 |
| -instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (a1, a2, a3, a4, a5, a6) |
426 |
| -instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (a1, a2, a3, a4, a5, a6, a7) |
| 422 | +-- These instances are defined directly because the generic names for tuples changed |
| 423 | +-- in 9.6 (https://gitlab.haskell.org/ghc/ghc/-/issues/24291). |
| 424 | +-- |
| 425 | +-- By defining our own instances the STuple2 identifier will be used in the hash and |
| 426 | +-- hence the same on all GHC versions. |
| 427 | + |
| 428 | +data STuple2 a b = STuple2 a b deriving (Generic) |
| 429 | +data STuple3 a b c = STuple3 a b c deriving (Generic) |
| 430 | +data STuple4 a b c d = STuple4 a b c d deriving (Generic) |
| 431 | +data STuple5 a b c d e = STuple5 a b c d e deriving (Generic) |
| 432 | +data STuple6 a b c d e f = STuple6 a b c d e f deriving (Generic) |
| 433 | +data STuple7 a b c d e f g = STuple7 a b c d e f g deriving (Generic) |
| 434 | + |
| 435 | +instance (Structured a1, Structured a2) => Structured (STuple2 a1 a2) |
| 436 | +instance (Structured a1, Structured a2) => Structured (a1, a2) where |
| 437 | + structure Proxy = structure @(STuple2 a1 a2) Proxy |
| 438 | + |
| 439 | +instance (Structured a1, Structured a2, Structured a3) => Structured (STuple3 a1 a2 a3) |
| 440 | +instance (Structured a1, Structured a2, Structured a3) => Structured (a1, a2, a3) where |
| 441 | + structure Proxy = structure @(STuple3 a1 a2 a3) Proxy |
| 442 | + |
| 443 | +instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (STuple4 a1 a2 a3 a4) |
| 444 | +instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (a1, a2, a3, a4) where |
| 445 | + structure Proxy = structure @(STuple4 a1 a2 a3 a4) Proxy |
| 446 | + |
| 447 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (STuple5 a1 a2 a3 a4 a5) |
| 448 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (a1, a2, a3, a4, a5) where |
| 449 | + structure Proxy = structure @(STuple5 a1 a2 a3 a4 a5) Proxy |
| 450 | + |
| 451 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (STuple6 a1 a2 a3 a4 a5 a6) |
| 452 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (a1, a2, a3, a4, a5, a6) where |
| 453 | + structure Proxy = structure @(STuple6 a1 a2 a3 a4 a5 a6) Proxy |
| 454 | + |
| 455 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (STuple7 a1 a2 a3 a4 a5 a6 a7) |
| 456 | +instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (a1, a2, a3, a4, a5, a6, a7) where |
| 457 | + structure Proxy = structure @(STuple7 a1 a2 a3 a4 a5 a6 a7) Proxy |
427 | 458 |
|
428 | 459 | instance Structured BS.ByteString where structure = nominalStructure
|
429 | 460 | instance Structured LBS.ByteString where structure = nominalStructure
|
|
0 commit comments