-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When elaborating dictionaries with subgoals, curry the application
fixes #36
- Loading branch information
1 parent
52ec4c9
commit b300a30
Showing
5 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#lang hackett | ||
|
||
(require (only-in racket/base for-syntax module submod)) | ||
|
||
(module shared hackett | ||
(provide (data Test-Result)) | ||
(data Test-Result test-success test-failure)) | ||
|
||
(module untyped racket/base | ||
(require (for-syntax racket/base) | ||
racket/promise | ||
(prefix-in r: rackunit/log) | ||
syntax/parse/define | ||
|
||
(only-in hackett [#%app @%app] : -> IO String Unit unit tuple) | ||
(only-in hackett/private/base with-dictionary-elaboration) | ||
(only-in hackett/private/prim io unsafe-run-io!) | ||
hackett/private/prim/type-provide | ||
|
||
(submod ".." shared)) | ||
|
||
(provide (typed-out [test-log! : {Test-Result -> (IO Unit)}] | ||
[println/error : {String -> (IO Unit)}]) | ||
test) | ||
|
||
(define (test-log! result) | ||
(io (λ (rw) | ||
(r:test-log! (equal? test-success (force result))) | ||
((tuple rw) unit)))) | ||
|
||
(define (println/error str) | ||
(io (λ (rw) | ||
(displayln (force str) (current-error-port)) | ||
((tuple rw) unit)))) | ||
|
||
(define-syntax-parser test | ||
[(_ e:expr) | ||
#'(module+ test | ||
(void (with-dictionary-elaboration (force (@%app unsafe-run-io! e)))))])) | ||
|
||
(require (submod "." shared) | ||
(submod "." untyped)) | ||
|
||
(provide test ==!) | ||
|
||
(defn ==! : (forall [a] (Eq a) (Show a) => {a -> a -> (IO Unit)}) | ||
[[x y] (if {x == y} | ||
(test-log! test-success) | ||
(do (println/error | ||
{"expectation failed:\n" | ||
++ " expected: " ++ (show y) ++ "\n" | ||
++ " given: " ++ (show x)}) | ||
(test-log! test-failure)))]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#lang hackett | ||
|
||
(require hackett/private/test) | ||
|
||
(test {(show (tuple 1 2)) ==! "(tuple 1 2)"}) |