Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created November 22, 2013 13:23
Show Gist options
  • Save swannodette/7599766 to your computer and use it in GitHub Desktop.
Save swannodette/7599766 to your computer and use it in GitHub Desktop.
(let [x (cons 1 nil)]
(+ x 1))
;; WARNING: cljs.core/+, all arguments must be numbers, got [cljs.core/Cons number] instead.
(let [x (interleave (repeat "foo") (repeat "bar"))]
(+ x 1))
;; WARNING: cljs.core/+, all arguments must be numbers, got [cljs.core/LazySeq number] instead.
@ericnormand
Copy link

Is that last line correct? [cljs.core/LazySeq number] ? Should be string, no?

@frenchy64
Copy link

@ericnormand interleave returns a lazy sequence, of characters in this case.

@swannodette
Copy link
Author

Note none of this is a replacement for what core.typed does, it's really only designed to handle the common non-higher order cases. If you need something more powerful than that, you know where to look :)

Getting the primitive arithmetic check in was just a fun way to kick off having more type information in the AST, the real benefit will be around eliminating protocol overheads where we can.

@ericnormand
Copy link

@frenchy64

(take 10 (interleave (repeat "foo") (repeat "bar"))) => ("foo" "bar" "foo" "bar" "foo" "bar" "foo" "bar" "foo" "bar")

@swannodette

It's definitely useful! Just wondering if it's a bug.

@swannodette
Copy link
Author

@ericnormand, sorry I understand the source of your confusion now, that vector is just the types of the argument list - the inference doesn't consider contents of collections - that's definitely outside the realm of what we want to handle in the ClojureScript compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment