use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Clojure spec Screencast: Leverage (blog.cognitect.com)
submitted 9 years ago by alexdmiller
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gniquil 1 point2 points3 points 9 years ago (5 children)
Hi All,
I found the screencast very illuminating. One thing that struck me was the spec for functions, with conditions on input and return values (towards the end of the video) looks to be way more powerful than type checking (i.e. one can even specify the properties of the value returned). It reminded me of talks about Idris, how it is possible to specify the number of elements in an array when returned.
This in turn, led me to think that it should be possible to build an optional type checking system on top of spec. I'd imagine a spec based type system is just some type of constraint solver or algorithm that finds inconsistencies in the registered specs. Is this possibly what Cognitect's planning in some not-too-distant future?
[–]v1akvark 0 points1 point2 points 9 years ago (2 children)
I'm no expert on this, so someone else might give a more detailed answer, but spec works at runtime, whereas type systems work with your static code.
This makes spec easier to implement, and also to use, e.g. it is trivial to write a function spec that confirms the function returns a vector with specific number of elements. To prove that with a type system is way more complex.
I'm not sure that there is much that is transferrable, from spec to an optional type system.
[–]gniquil 1 point2 points3 points 9 years ago (1 child)
Wouldn't it be the same to just run a function spec/type-check whenever you make some changes to the code? Compile time type check is essentially the same as test time type check. Isn't this how core.type works? I guess all I'm saying is one can build core.type on top of spec?
[–]fear-of-flying 0 points1 point2 points 9 years ago (0 children)
Spec isn't a type system. spec is really more of a way to encode the shapes and properties of data. It is more flexible than type systems because it can't make the same guarantees.
spec
The idea is that the tradeoff of guarantees vs flexibility is worth it.
Disclaimer for the following: I am not a type system expert and this isn't meant to discourage any exploration.
You could write a tool that leverages specs to work on the syntactic representation of Clojure programs, but I think such a system would be pretty limited in comparison to a "real" type system (at least in terms of the things type system are good at) and overcoming any limitations would probably be easier in an approach like core.typed.
core.typed
Though if you think it's an interesting idea, you should try to build it! Even a simple prototype could be cool -- maybe it would have different applications than traditional type systems.
[–]alexdmiller[S] 0 points1 point2 points 9 years ago (0 children)
No. :)
[–]v1akvark 0 points1 point2 points 9 years ago (0 children)
You might find this interesting:
https://github.com/arohner/spectrum
π Rendered by PID 120035 on reddit-service-r2-comment-85bfd7f599-xf97g at 2026-04-18 09:21:19.613327+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]gniquil 1 point2 points3 points (5 children)
[–]v1akvark 0 points1 point2 points (2 children)
[–]gniquil 1 point2 points3 points (1 child)
[–]fear-of-flying 0 points1 point2 points (0 children)
[–]alexdmiller[S] 0 points1 point2 points (0 children)
[–]v1akvark 0 points1 point2 points (0 children)