Skip to content

Reading The Error Messages

Kris Jenkins edited this page Aug 30, 2014 · 2 revisions

Let's look at a typical error, piece by piece:

Type Error (clj.util.map:14:23) Polymorphic function clojure.core/keys could not be applied to arguments:

The first part of the error tells you this concerns a call to clojure.core/keys. You can lookup the type with (cf keys):

(All [k] [(Map k Any) -> (Seq k) :object {:id 0 :path [Keys]}])

The error is basically summarising this polymorphic type juxtaposed with the actual types provided to the function.

Polymorphic Variables:
    k

The Polymorphic Variables list all the variables in the All binder and their type bounds. k is the only variable, which has essentially no bounds, so k is displayed.

Domains:
    (t/Map k Any)

The Domains list all the parameter types (to the left of the ->) in order. If multiple arities were specified with Fn, each parameter list would be displayed sequentially.

Arguments:
    (t/Option (t/Map k v1))

The Arguments show you what types are actually passed to the function.

Ranges:
    (t/Seq k) :object {:path [Keys], :id 0}

The Ranges list all the return types (to the right of the ->) in order.

Sometimes there is an Expected type, which must match up with a Range in the same way all the Arguments must match up with a Domain.

We can diagnose this error by comparing the Domains with the Arguments. The list of Arguments must fit under one list of Domains, and the match is attempted top-down. If no Domains fit with the Arguments, we get a type error like this; it's often too complicated to pinpoint exactly where the constraint algorithm failed, so the user is presented with a lot of information.

Clone this wiki locally