Re: [ANN] defn-spec, define your specs inline with your function

2019-04-01 Thread Alan Thompson
Looks interesting!  Definitely need to check this out.
Alan

On Sun, Mar 31, 2019 at 12:44 AM Daniel Compton <
daniel.compton.li...@gmail.com> wrote:

> Hi folks
>
> I've released 0.1.0 of defn-spec
> , a library that lets you
> define your function specs inline with your function definitions.
>
> A quick example, defn-spec lets you write:
>
> (ds/defn to-zoned-dt :- ::zoned-date-time
>   [instant :- ::instant
>zone-id :- ::zone-id]
>   (ZonedDateTime/ofInstant instant zone-id))
>
> instead of:
>
> (defn to-zoned-dt
>   [instant zone-id]
>   (ZonedDateTime/ofInstant instant zone-id))
>
> (s/fdef to-zoned-dt
> :args (s/cat :instant ::instant :zone-id ::zone-id)
> :ret ::zoned-date-time)
>
> If you're thinking "that looks a lot like Schema's defn macro", then you'd
> be right. defn-spec uses the same syntax and much of the implementation of
> Schema's defn macro.
>
> I wrote more background in the announcement post
> , and there
> are more details on GitHub .
> I hope you find it useful!
>
> Thanks, Daniel.
>
> --
> 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.
>

-- 
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.


[ANN] defn-spec, define your specs inline with your function

2019-03-31 Thread Daniel Compton
Hi folks

I've released 0.1.0 of defn-spec
, a library that lets you
define your function specs inline with your function definitions.

A quick example, defn-spec lets you write:

(ds/defn to-zoned-dt :- ::zoned-date-time
  [instant :- ::instant
   zone-id :- ::zone-id]
  (ZonedDateTime/ofInstant instant zone-id))

instead of:

(defn to-zoned-dt
  [instant zone-id]
  (ZonedDateTime/ofInstant instant zone-id))

(s/fdef to-zoned-dt
:args (s/cat :instant ::instant :zone-id ::zone-id)
:ret ::zoned-date-time)

If you're thinking "that looks a lot like Schema's defn macro", then you'd
be right. defn-spec uses the same syntax and much of the implementation of
Schema's defn macro.

I wrote more background in the announcement post
, and there are
more details on GitHub . I hope
you find it useful!

Thanks, Daniel.

-- 
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.