Last active
August 29, 2015 13:59
-
-
Save jneen/10952058 to your computer and use it in GitHub Desktop.
core.typed and core.match failing to get along, with multimethods this time
This file contains hidden or 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
(ns type-test.lambda | |
(require [clojure.core.typed :refer :all] | |
[clojure.core.match :refer [match]])) | |
(def-alias Expr "An expression" | |
(Rec [e] | |
(U '[(Value :var) Symbol] | |
'[(Value :lam) Symbol e] | |
'[(Value :app) e e]))) | |
(ann free? (Fn [Expr Symbol -> Boolean])) | |
(defmulti free? (fn [expr var] (first expr))) | |
(defmethod free? :var [[_ sym] var] (= sym var)) | |
(defmethod free? :lam [[_ arg body] var] (and (not= arg var) (free? body var))) | |
(defmethod free? :app [[_ func expr] var] (or (free? func var) (free? expr var))) |
This file contains hidden or 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
Initializing core.typed ... | |
Building core.typed base environments ... | |
Finished building base environments | |
"Elapsed time: 4289.650169 msecs" | |
core.typed initialized. | |
Start collecting type-test.lambda | |
Finished collecting type-test.lambda | |
Collected 1 namespaces in 5638.999324 msecs | |
Start checking type-test.lambda | |
Checked type-test.lambda in 421.090446 msecs | |
Checked 1 namespaces (approx. 15 lines) in 6064.178849 msecs | |
Type Error (type_test/lambda.clj:14:62) Type mismatch: | |
Expected: Expr | |
Actual: (U nil type-test.lambda/Expr) | |
in: (free? body var) | |
Type Error (type_test/lambda.clj:15:47) Type mismatch: | |
Expected: Expr | |
Actual: (U Symbol type-test.lambda/Expr) | |
in: (free? func var) | |
Type Error (type_test/lambda.clj:15:64) Type mismatch: | |
Expected: Expr | |
Actual: (U nil type-test.lambda/Expr) | |
in: (free? expr var) | |
Type Checker: Found 3 errors | |
Found errors | |
Subprocess failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment