Created
March 5, 2014 00:41
-
-
Save echosa/9358930 to your computer and use it in GitHub Desktop.
An issue I'm having with typed Clojure
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
(ns greed.coords | |
(:require [clojure.core.typed :refer [ann]])) | |
(ann get-next-coordinate-northeast | |
[NonEmptySeqable (Option Number) (Option Number) -> (Option (IPersistentList Number))]) | |
(defn get-next-coordinate-northeast [grid x y] | |
(when-not (or (nil? x) (nil? grid) (>= x (- (count (first grid)) 1)) | |
(nil? y) (<= y 0)) | |
(list (+ x 1) (- y 1)))) | |
;; greed.coords> (clojure.core.typed/check-ns) | |
;; Start collecting greed.coords | |
;; Finished collecting greed.coords | |
;; Collected 1 namespaces in 22.57 msecs | |
;; Start checking greed.coords | |
;; Checked greed.coords in 237.739 msecs | |
;; Checked 1 namespaces (approx. 72 lines) in 260.809 msecs | |
;; Type Error (greed/coords.clj:22:54) Polymorphic function clojure.core/first could not be applied to arguments: | |
;; Polymorphic Variables: | |
;; x | |
;; | |
;; Domains: | |
;; (HVec [x Any *]) | |
;; (Option (EmptySeqable x)) | |
;; (NonEmptySeqable x) | |
;; (Option (clojure.lang.Seqable x)) | |
;; | |
;; Arguments: | |
;; clojure.core.typed/NonEmptySeqable | |
;; | |
;; Ranges: | |
;; x | |
;; nil | |
;; x | |
;; (Option x) | |
;; | |
;; in: (clojure.core/first grid) | |
;; in: (clojure.lang.Numbers/gte x (clojure.lang.Numbers/minus (clojure.lang.RT/count (clojure.core/first grid)) 1)) | |
;; | |
;; | |
;; ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4327) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heterogeneous vectors are much better supported than heterogeneous lists or seqs.