haskell: deriving (Eq, Show) for ADTs (+11 tests, 565/565)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Parser parses optional deriving clause; only appended to AST when non-empty. hk-bind-decls! data arm generates dictShow_Con / dictEq_Con per constructor. hk-binop == and /= now deep-force both sides (SX dict equality is by reference — two thunks wrapping the same value compared as not-equal without this). Three token-type fixes in the deriving parser (lparen/rparen/comma, not "special"). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1250,7 +1250,8 @@
|
||||
(let
|
||||
((name (get (hk-advance!) "value"))
|
||||
(tvars (hk-parse-tvars))
|
||||
(cons-list (list)))
|
||||
(cons-list (list))
|
||||
(deriving-list (list)))
|
||||
(when
|
||||
(hk-match? "reservedop" "=")
|
||||
(do
|
||||
@@ -1267,7 +1268,34 @@
|
||||
(append! cons-list (hk-parse-con-def))
|
||||
(hk-dc-loop)))))
|
||||
(hk-dc-loop)))
|
||||
(list :data name tvars cons-list))))
|
||||
(when
|
||||
(hk-match? "reserved" "deriving")
|
||||
(do
|
||||
(hk-advance!)
|
||||
(cond
|
||||
((hk-match? "lparen" nil)
|
||||
(do
|
||||
(hk-advance!)
|
||||
(define
|
||||
hk-der-loop
|
||||
(fn
|
||||
()
|
||||
(when
|
||||
(hk-match? "conid" nil)
|
||||
(do
|
||||
(append!
|
||||
deriving-list
|
||||
(get (hk-advance!) "value"))
|
||||
(when (hk-match? "comma" nil) (hk-advance!))
|
||||
(hk-der-loop)))))
|
||||
(hk-der-loop)
|
||||
(hk-expect! "rparen" nil)))
|
||||
((hk-match? "conid" nil)
|
||||
(append! deriving-list (get (hk-advance!) "value"))))))
|
||||
(if
|
||||
(empty? deriving-list)
|
||||
(list :data name tvars cons-list)
|
||||
(list :data name tvars cons-list deriving-list)))))
|
||||
(define
|
||||
hk-parse-class
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user