Skip to content

Commit d720a8a

Browse files
hyperpolymathclaude
andcommitted
fix(layout): add DecEq (a,b) instance to resolve WHT_Struct DecEq
WHT_Struct fields are List (String, WasmValType). Resolving decEq (WHT_Struct xs) (WHT_Struct ys) requires DecEq (String, WasmValType), which in turn requires DecEq (a,b). Prelude provides DecEq String and DecEq (List a); the pair instance was missing. Adding it before the mutual block completes the resolution chain: DecEq WasmValType (mutual) → DecEq (String, WasmValType) [new pair instance] → DecEq (List (String, WasmValType)) [Prelude] → decEq xs ys in WHT_Struct ✓ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 69a33af commit d720a8a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/abi/layout/Types.idr

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,27 @@ DecEq WasmPrimitive where
120120
decEq WasmFuncRef WasmF32 = No (\case Refl impossible)
121121
decEq WasmFuncRef WasmF64 = No (\case Refl impossible)
122122

123+
-- `WHT_Struct` fields are `List (String, WasmValType)`.
124+
-- `DecEq String` is in Prelude; `DecEq (List a)` is in Prelude given `DecEq a`.
125+
-- `DecEq (a, b)` is NOT in Prelude in all Idris2 versions, so we provide it here.
126+
-- This instance must be declared BEFORE the mutual block so it is in scope when
127+
-- `decEq xs ys` is resolved inside the `WHT_Struct` case.
128+
129+
DecEq a => DecEq b => DecEq (a, b) where
130+
decEq (x1, y1) (x2, y2) with (decEq x1 x2)
131+
_ | No neq = No (\case Refl => neq Refl)
132+
_ | Yes Refl with (decEq y1 y2)
133+
_ | Yes Refl = Yes Refl
134+
_ | No neq = No (\case Refl => neq Refl)
135+
123136
-- Mutual DecEq for WasmHeapType and WasmValType.
124137
-- The two types are mutually recursive (WasmHeapType contains WasmValType and
125138
-- vice-versa), so both instances must be declared together.
139+
-- Resolution chain for WHT_Struct:
140+
-- DecEq WasmValType (mutual)
141+
-- → DecEq (String, WasmValType) (pair instance above)
142+
-- → DecEq (List (String, WasmValType)) (Prelude)
143+
-- → decEq xs ys in WHT_Struct case ✓
126144

127145
mutual
128146
DecEq WasmHeapType where

0 commit comments

Comments
 (0)