foo.spec?

411 views
Skip to first unread message

Rich Morin

unread,
Dec 29, 2016, 1:17:47 PM12/29/16
to Clojure
Does anyone know of efforts to port clojure.spec to other languages?  I thought I had seen someone mention versions for Haskell and Scala, but I can't find any information on this.  FWIW, my interest is in having elixir.spec and/or ruby.spec...

-r

Jamie English

unread,
Dec 29, 2016, 9:24:39 PM12/29/16
to Clojure
Hi Rich,

I've spent some time over the holidays working on a Ruby port of clojure.spec: https://github.com/english/speculation. It's early days - I've mostly implemented validation/conforming, however no data generation - but I hope to have something close to feature parity with clojure.spec within the next couple of months.

Cheers,
Jamie

Rich Morin

unread,
Dec 29, 2016, 10:14:49 PM12/29/16
to Clojure
On Thursday, December 29, 2016 at 6:24:39 PM UTC-8, Jamie English wrote:
I've spent some time over the holidays working on a Ruby port of clojure.spec: ...

I'm delighted to hear this.  One of the things I've been wondering about is how a Ruby API for spec would look.  Could you provide a precis (e.g., some simple cases, annotated for noobs, in both clojure.spec and speculation)?

-r

 

Alex Miller

unread,
Dec 31, 2016, 12:10:27 PM12/31/16
to Clojure
There's a Javascript port - https://github.com/prayerslayer/js.spec

Jamie English

unread,
Jan 2, 2017, 9:15:16 PM1/2/17
to Clojure
It's reassuring to hear there's interest! A précis sounds like a good idea. The API is pretty close to Clojure's right now but once the rest of the functionality is ported over I'll make it more Ruby-like and do a write-up. I'll reply here when I push a usable release.

Rich Morin

unread,
Jan 5, 2017, 4:31:07 AM1/5/17
to Clojure
As Stuart Halloway points out, "all code is data, but all data is not code". That said, I'd like to see spec lean as far as possible in the direction of simply being based on data structures. By way of motivation, let's suppose that I have a Sinatra (Ruby) server that is communicating with Elm or JS client-side code and/or a Clojure or Elixir back end. If I could define specs in a cross-platform manner, I could use the same specs to define messages throughout the system. FWIW, my preference would be to use transit.js to facilitate transfer of higher-level data structures among the components.

-r

Xiyang Chen

unread,
Jan 22, 2017, 10:16:38 AM1/22/17
to Clojure
Hi, 

In addition to js.spec, here is another alternative I made: Clause.js

What's currently working is conformation and validation for regex specs & function specs. Next on the roadmap is data generation. 

I've also made a sub-library for documentation generation called clausejs-docgen. I have been using this library to generate Clause.js's own documentation, which has been a pretty fun experiment. 

There is also a "syntax" function that takes an fspec, computes all the possibilities (on all the "or" specs contained within the fspec), and generates a list of concise syntax representations. You can find an example here.

Cheers,
Xiyang

Jamie English

unread,
Apr 22, 2017, 5:42:23 PM4/22/17
to clo...@googlegroups.com
Hi,

It took a little longer than expected, but Speculation, a Ruby port of clojure.spec, is now in a good place. It has the main features of clojure.spec: validation, conforming, generation, and instrumentation. What's missing is an equivalent of `s/describe` and documentation integration.

My goal for Speculation is to provide, as close as possible, clojure.spec in Ruby. There's nothing original in there - the API and implementation are largely lifted from clojure.spec (with a few parentheses re-arranged).

If there are any Rubyists on this list wishing we had a clojure.spec equivalent then I'd be keen to hear your thoughts on Speculation. I have a port of Alex Miller's Spec guide and the Codebreaker exercise from David Chelimsky's Interactive development with clojure.spec blog post that show off most features, as well as a simple web app demonstrating API request validation and error reporting.

The documentation and examples are a little slim at the moment, and probably make little sense without prior exposure to clojure.spec. I plan to address this before sharing it with the larger Ruby community.

Jamie

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+unsubscribe@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 a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/LHg1eS3uBbs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages