Hi,
Very excited to *finally* merge Di Xu's GSoC 2014 work. This is awesome stuff!
We can now type check usages of hash-map/assoc/apply in much finer detail.
[org.clojure/core.typed "0.3.31"]
core.typed can now support different patterns of "rest" arguments -- think `hash-map`
and `assoc`.
There are two new kinds of rest arguments.
1. prest arguments, denoted by. Like *, but written <*
2. pdot arguments, denoted by. Like ... but written <...
Think of <* as "splicing *" and <... as "splicing ...".
eg. Here's the new type of hash-map:
|
clojure.core/hash-map (All [x y] [(HSequential [x y] :repeat true) <* -> (Map x y)]) |
|
It uses <* to enforce paired arguments. It is now a static type error to provide an
odd number of arguments to hash-map.
The :repeat argument to HSequential repeats the fixed members
an infinite number of times. The type (HSequential [x y] :repeat true)
is the type of all heterogeneous sequences with even counts.
The <* "splices" this into the function parameter list. Now
(HSequential [x y] :repeat true) <*
means any even number of arguments are allowed.
"apply" and "assoc" also have similar updated types, using <...
Please try out these functions and report if checking them is more useful.
This is only the tip of the iceberg of what Di has implemented --- please respond
if more detail/clarifications are needed.
Thanks!
Ambrose