Hi all,

Coming from python, I use dataclasses 
<https://docs.python.org/3/library/dataclasses.html> a lot to tie complex 
collections of data together. I like using them in combination with type 
hints so that it's clearer to me at a glance what kind of data a function 
is processing.  When my data starts to look like a dict of dicts of lists, 
I turn to dataclasses to help my simplify.

So far in my Clojure journey, I've stumbled across two features that could 
help me do something similar.  First are datatypes 
<https://clojure.org/reference/datatypes> (deftype, defrecord), and second 
is using maps with spec <https://clojure.org/guides/spec>.  Based on my 
reading, using spec to define types seems like a really flexible system 
that does built in testing for me.  I was surprised to read that specs 
can't quite be treated like types 
though: https://ask.clojure.org/index.php/10464/can-i-use-spec-as-type-hint.  
Maybe the intention is to use the :pre and :post keys in a function's 
options as type hints?

I'm curious if I'm thinking along the right lines here, or if there are 
other language features I could be looking at.  Also curious if anyone has 
suggestions for books or articles that explore data typing options in 
Clojure.

Thanks,

 - Kovas

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/a5718e8b-71a6-40d5-b1da-ca2cdb10a71en%40googlegroups.com.

Reply via email to