haskell: reject untypeable programs — hk-typecheck + hk-run-typed (+9 tests, 464/464)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -790,3 +790,25 @@ negate x = 0 - x
|
||||
(fn
|
||||
(src)
|
||||
(hk-deep-force (hk-eval (hk-core-expr src) (hk-dict-copy hk-env0)))))
|
||||
|
||||
(define
|
||||
hk-typecheck
|
||||
(fn
|
||||
(prog)
|
||||
(let
|
||||
((results (hk-infer-prog prog (hk-type-env0))))
|
||||
(let
|
||||
((errors (filter (fn (r) (= (first r) "err")) results)))
|
||||
(when (not (empty? errors)) (raise (nth (first errors) 1)))))))
|
||||
|
||||
(define
|
||||
hk-run-typed
|
||||
(fn
|
||||
(src)
|
||||
(let
|
||||
((prog (hk-core src)))
|
||||
(begin
|
||||
(hk-typecheck prog)
|
||||
(let
|
||||
((env (hk-eval-program prog)))
|
||||
(cond ((has-key? env "main") (get env "main")) (:else env)))))))
|
||||
|
||||
Reference in New Issue
Block a user