Fork me on GitHub
#clojure-spec
<
2020-03-26
>
ben.sless06:03:15

I have a bit of a philosophical question: I watched several talks about spec and it's pretty clear how you'd use it for domain modelling when starting from scratch, but several mentioned its benefits in speccing an existing codebase. Any tips on where and how to start with speccing an existing code base?

robertfrederickwarner06:03:51

I would start by adding fdefs for key functions

timur05814:03:28

Maybe it's also a good idea to spec places where pieces of code, written by different people in the team, meet. To set expectations and settle future disputes.

sogaiu07:03:58

there was this bit from stuart halloway: http://blog.cognitect.com/blog/2017/6/19/improving-on-types-specing-a-java-library -- may be that's of some use?

bertofer22:03:07

Hi, does clojure-spec provide or will provide a way to convert schema maps (unqualified) without explicitly specifying spec on every val? e.g.

From (spec/schema {:type #{:open :closed}}) -> (spec/schema {:type (spec/spec #{:open :closed})})
Seems like a map traversal, is it something that can already be done with normal clojure on the context of spec and schemas?

alexmiller23:03:16

I dont think you should even need that?

bertofer00:03:56

yeah on a second thought it’s not very useful

bertofer00:03:32

Also because it would only apply to spec from simple predicates, not other types of specs

alexmiller00:03:53

it already does what you're asking, unless I misunderstand what you're asking

bertofer10:03:31

True, I was confused by this in the schema and select wiki [::a ::b {:c (s/spec int?)}] , but in the unqualified keys section is shown as I wanted