Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 6e1f307

Browse files
committed
[CDEC-403] Remove partial field accessors from InvariantViolation
1 parent 81e3b2d commit 6e1f307

File tree

1 file changed

+22
-42
lines changed

1 file changed

+22
-42
lines changed

wallet-new/test/unit/Wallet/Inductive/Invariants.hs

+22-42
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,12 @@ invariant name e p = void . interpret notChecked ((:[]) . e) p'
5656
notChecked :: History h a
5757
-> InvalidInput h a
5858
-> InvariantViolation h a
59-
notChecked history reason = InvariantNotChecked {
60-
invariantNotCheckedName = name
61-
, invariantNotCheckedReason = reason
62-
, invariantNotCheckedEvents = history
63-
}
59+
notChecked history reason = InvariantNotChecked name reason history
6460

6561
violation :: History h a
6662
-> InvariantViolationEvidence
6763
-> InvariantViolation h a
68-
violation history ev = InvariantViolation {
69-
invariantViolationName = name
70-
, invariantViolationEvidence = ev
71-
, invariantViolationEvents = history
72-
}
64+
violation history ev = InvariantViolation name ev history
7365

7466
p' :: History h a
7567
-> [Wallet h a]
@@ -82,28 +74,18 @@ invariant name e p = void . interpret notChecked ((:[]) . e) p'
8274
-- | Invariant violation
8375
data InvariantViolation h a =
8476
-- | Invariance violation
85-
InvariantViolation {
86-
-- | Name of the invariant
87-
invariantViolationName :: Text
88-
89-
-- | Evidence that the invariant was violated
90-
, invariantViolationEvidence :: InvariantViolationEvidence
91-
92-
-- | The evens that led to the error
93-
, invariantViolationEvents :: History h a
94-
}
77+
-- invariantViolationName = Name of the invariant
78+
-- invariantViolationEvidence = Evidence that the invariant
79+
-- was violated
80+
-- invariantViolationEvents = The evennts that led to the error
81+
InvariantViolation !Text !InvariantViolationEvidence !(History h a)
9582

9683
-- | The invariant was not checked because the input was invalid
97-
| InvariantNotChecked {
98-
-- | Name of the invariant
99-
invariantNotCheckedName :: Text
100-
101-
-- | Why did we not check the invariant
102-
, invariantNotCheckedReason :: InvalidInput h a
103-
104-
-- | The events that led to the error
105-
, invariantNotCheckedEvents :: History h a
106-
}
84+
-- InvariantNotChecked
85+
-- invariantNotCheckedName = Name of the invariant
86+
-- invariantNotCheckedReason = Why did we not check the invariant
87+
-- invariantNotCheckedEvents = The events that led to the error
88+
| InvariantNotChecked !Text !(InvalidInput h a) !(History h a)
10789

10890
{-------------------------------------------------------------------------------
10991
Evidence that an invariant was violated
@@ -288,20 +270,12 @@ walletEquivalent lbl e e' = void .
288270
notChecked :: History h a
289271
-> InvalidInput h a
290272
-> InvariantViolation h a
291-
notChecked history reason = InvariantNotChecked {
292-
invariantNotCheckedName = lbl
293-
, invariantNotCheckedReason = reason
294-
, invariantNotCheckedEvents = history
295-
}
273+
notChecked history reason = InvariantNotChecked lbl reason history
296274

297275
violation :: History h a
298276
-> InvariantViolationEvidence
299277
-> InvariantViolation h a
300-
violation history ev = InvariantViolation {
301-
invariantViolationName = lbl
302-
, invariantViolationEvidence = ev
303-
, invariantViolationEvents = history
304-
}
278+
violation history ev = InvariantViolation lbl ev history
305279

306280
p :: History h a
307281
-> [Wallet h a]
@@ -332,7 +306,10 @@ walletEquivalent lbl e e' = void .
332306
-------------------------------------------------------------------------------}
333307

334308
instance (Hash h a, Buildable a) => Buildable (InvariantViolation h a) where
335-
build InvariantViolation{..} = bprint
309+
build (InvariantViolation
310+
invariantViolationName
311+
invariantViolationEvidence
312+
invariantViolationEvents) = bprint
336313
( "InvariantViolation "
337314
% "{ name: " % build
338315
% ", evidence: " % build
@@ -342,7 +319,10 @@ instance (Hash h a, Buildable a) => Buildable (InvariantViolation h a) where
342319
invariantViolationName
343320
invariantViolationEvidence
344321
invariantViolationEvents
345-
build (InvariantNotChecked{..}) = bprint
322+
build (InvariantNotChecked
323+
invariantNotCheckedName
324+
invariantNotCheckedReason
325+
invariantNotCheckedEvents) = bprint
346326
( "InvariantNotChecked "
347327
% "{ name: " % build
348328
% ", reason: " % build

0 commit comments

Comments
 (0)