I enabled opt-in macro spec inference in core.typed 0.4.3, via
a :spec-macros option.

Here's an example with slingshot:

Setup 
<https://github.com/frenchy64/slingshot/commit/6b2548171add81399e81ccbc51ec0cce4de38670>
Inferred Macro specs 
<https://github.com/frenchy64/slingshot/commit/df20eadb17abc6677f721763c5f5059a46693517#diff-9bd43a8aebd660e08a7c41cd0f0a13d0R74>

Thanks,
Ambrose

On Friday, October 13, 2017 at 5:46:36 PM UTC-4, Ambrose Bonnaire-Sergeant 
wrote:
>
> This 
> <https://github.com/clojure/core.typed/blob/0552a59708bc20d26b2875776ab9cf09bbf62075/module-check/src/main/clojure/clojure/core/typed/runtime_infer.clj#L1250-L1273>
>  
> is pretty much the extent of my macro heuristics: binding forms are
> often the first argument, and it's usually a vector. Also, [& body] 
> arguments
> are common.
>
> On Friday, October 13, 2017 at 5:44:07 PM UTC-4, Ambrose Bonnaire-Sergeant 
> wrote:
>>
>> Potentially. Actually, it currently instruments and gathers data about 
>> macros, but doesn't 
>> <https://github.com/clojure/core.typed/blob/0552a59708bc20d26b2875776ab9cf09bbf62075/module-check/src/main/clojure/clojure/core/typed/runtime_infer.clj#L5067>
>> output them 
>> <https://github.com/clojure/core.typed/blob/0552a59708bc20d26b2875776ab9cf09bbf62075/module-check/src/main/clojure/clojure/core/typed/runtime_infer.clj#L5067>
>>  
>> because I haven't thought of very good heuristics to guess specs for common
>> macros (in particular heterogeneous/repeating lists and vectors are 
>> troublesome, I haven't
>> tried outputting any spec regex ops).
>>
>> Thanks,
>> Ambrose
>>
>> On Friday, October 13, 2017 at 3:54:22 PM UTC-4, Colin Fleming wrote:
>>>
>>> This looks great! Can this be used to infer macro specs based on 
>>> examples of usage?
>>>
>>> On 14 October 2017 at 04:30, Ambrose Bonnaire-Sergeant <
>>> abonnair...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Happy to announce a new set of tools to *automatically*
>>>> *generate* types and specs for your projects.
>>>>
>>>> *Dependency information:*
>>>> 1. core.typed <https://github.com/clojure/core.typed>
>>>>     [org.clojure/core.typed "0.4.2"]
>>>> 2. lein-typed <https://github.com/typedclojure/lein-typed>
>>>>     [lein-typed "0.4.2"]
>>>> 3. boot-typedclojure 
>>>> <https://github.com/typedclojure/boot-typedclojure>
>>>>   [org.typedclojure/boot-typedclojure "0.1.0"]
>>>>
>>>> *Tutorial:*
>>>> Here's how to try it out (for Lein projects using clojure.test):
>>>>
>>>> 1. Add {:user {:plugins [[lein-typed "0.4.2"]]}} to your 
>>>> ~/.lein/profiles.clj
>>>> 2. Add a runtime dependency to [org.clojure/core.typed "0.4.2"] in 
>>>> your chosen Lein project.clj
>>>> 3. To infer specs: Run lein typed infer-spec <insert-ns> 
>>>> 4. To infer types: Run lein typed infer-type <insert-ns>
>>>>
>>>> WARNING: This tool *rewrites your files*. Only try with backed up code.
>>>>
>>>> *Some examples:*
>>>> *clj-time:*
>>>> *- *Spec setup 
>>>> <https://github.com/frenchy64/clj-time/commit/1df3be64a677a96f1c78520f35facba34e06da63>
>>>>  
>>>> + spec results 
>>>> <https://github.com/frenchy64/clj-time/commit/c3b47cac8e849c952b7df5e7106d70e65c0bbd08>
>>>> - Types setup 
>>>> <https://github.com/frenchy64/clj-time/commit/e3796332dc62002fa5ce5b5ab2e128328dc00077>
>>>>  
>>>> + types results 
>>>> <https://github.com/frenchy64/clj-time/commit/8c2f28ace006c1f28d6ef3aebdec9a6d176c9030>
>>>>
>>>> *cheshire*
>>>> *- *Spec setup 
>>>> <https://github.com/frenchy64/cheshire/commit/4f8d4b61b9460113ec25c62489e8918e69405ca8>
>>>>  
>>>> + spec results 
>>>> <https://github.com/frenchy64/cheshire/commit/3e391d933c2293fdcc4d192bbeff61ff7e0356dd>
>>>> - Types setup 
>>>> <https://github.com/frenchy64/cheshire/commit/6b1f0f730cb9c74b1daf13de11ddfeb23ce27383>
>>>>  
>>>> + types results 
>>>> <https://github.com/frenchy64/cheshire/commit/0cb14593841360a1391efc96d2370bd57205ac7a>
>>>>
>>>> (Note: use the latest core.typed versions to reproduce on your machines)
>>>>
>>>> *Hints:*
>>>> This tool instruments your namespace and runs your test suite. This
>>>> can be expensive. Try these options:
>>>>
>>>> *   Choose lein test selectors (here: [:integration :generative] 
>>>> selectors)*
>>>>   lein typed infer-spec <insert-ns> :test-selectors "[:integration 
>>>> :generative]"
>>>>
>>>> *   Timeout individual tests (1000ms timeout)*
>>>>   lein typed infer-spec <insert-ns> :test-timeout-ms 1000
>>>>
>>>> If annotation generation hangs, try these options:
>>>>
>>>> *   Disable recursive type inference*
>>>>   lein typed infer-spec <insert-ns> :infer-opts 
>>>> "{:no-squash-vertically true}"
>>>>
>>>> If you see "No such namespace: s", try deleting existing automatically 
>>>> generated specs/types before regenerating them. (git checkout works well 
>>>> here)
>>>>
>>>>
>>>>
>>>> *Reply* with your generated specs & types!
>>>>
>>>> Thanks,
>>>> Ambrose
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@googlegroups.com
>>>> Note that posts from new members are moderated - please be patient with 
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+u...@googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to clojure+u...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to