Skip to content

Commit 258f7dc

Browse files
Unisayclaude
andcommitted
test(Value): use Foldable combinators for succeeded and extractValue
Replace explicit pattern matching with more idiomatic Foldable combinators: - `succeeded = not . null` - checks if result is non-empty (success) - `extractValue = foldr const err` - extracts value or errors on failure This leverages BuiltinResult's Foldable instance for more concise code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fc0dbcc commit 258f7dc

File tree

1 file changed

+2
-7
lines changed
  • plutus-core/plutus-core/test/Value

1 file changed

+2
-7
lines changed

plutus-core/plutus-core/test/Value/Spec.hs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,8 @@ prop_unionCommutative v v' =
6464

6565
prop_unionAssociative :: Value -> Value -> Value -> Property
6666
prop_unionAssociative v1 v2 v3 =
67-
let succeeded (BuiltinSuccess _) = True
68-
succeeded (BuiltinSuccessWithLogs _ _) = True
69-
succeeded (BuiltinFailure _ _) = False
70-
71-
extractValue (BuiltinSuccess v) = v
72-
extractValue (BuiltinSuccessWithLogs _ v) = v
73-
extractValue (BuiltinFailure _ _) = error "extractValue called on BuiltinFailure"
67+
let succeeded = not . null
68+
extractValue = foldr const (error "extractValue called on BuiltinFailure")
7469

7570
r23 = V.unionValue v2 v3
7671
r12 = V.unionValue v1 v2

0 commit comments

Comments
 (0)