haskell: dict-passing elaborator — runtime dispatch via hk-mk-lazy-builtin (+3 tests, 506/506)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
This commit is contained in:
@@ -32,4 +32,29 @@
|
||||
(has-key? (get env-full "dictMyEq_Int") "myEq")
|
||||
true)
|
||||
|
||||
(hk-test
|
||||
"dispatch: single-arg method works"
|
||||
(hk-deep-force
|
||||
(hk-run
|
||||
"class Describable a where\n describe :: a -> String\ninstance Describable Int where\n describe x = \"an integer\"\nmain = describe 42"))
|
||||
"an integer")
|
||||
|
||||
(hk-test
|
||||
"dispatch: second instance (Bool)"
|
||||
(hk-deep-force
|
||||
(hk-run
|
||||
"class Describable a where\n describe :: a -> String\ninstance Describable Bool where\n describe x = \"a boolean\"\ninstance Describable Int where\n describe x = \"an integer\"\nmain = describe True"))
|
||||
"a boolean")
|
||||
|
||||
(hk-test
|
||||
"dispatch: error on unknown instance"
|
||||
(guard
|
||||
(e (true (>= (index-of e "No instance") 0)))
|
||||
(begin
|
||||
(hk-deep-force
|
||||
(hk-run
|
||||
"class Describable a where\n describe :: a -> String\nmain = describe 42"))
|
||||
false))
|
||||
true)
|
||||
|
||||
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}
|
||||
Reference in New Issue
Block a user