On Wednesday, April 30, 2014 1:03:24 PM UTC-5, Gregg Reynolds wrote:

> The one thing that I think would be genuinely useful and developer 
> friendly with respect to Clojure is a means of making type signatures 
> explicit.  Clojure may be dynamically typed, but everything has an intended 
> type, and I would like to see it.  I'm thinking of something along the way 
> Haskell and other languages express type sigs.  The paradigmatic example is 
> factorial (or fibonacci).  So given a factorial function "fact" I want to 
> be able to write something like (type-sig fact) and get something like "Int 
> -> Int"
>

I think this is a great idea.  A type-sig functions is a nice idea, but one 
can do this now, by adding to docstrings.  I am going to think about adding 
something like this to the docstrings for my own code.  Sean made an 
interesting point about core.typed, but I'm not sure whether it gets in the 
way of documenting intended signatures.  Jony suggested Prismatic/schema.  
That looks like a useful tool, but it wasn't clear to me, without 
installing it an playing with it for a bit, whether it generates nice 
signatures as documentation that can be called up in the REPL, IDEs, etc.  
(It also seems to be Clojurescript-specific at this point.)

It seems as if a syntax for intended type signatures is obviously not 
entirely simple, for at least two reasons. 

1. Functions have complex intended type signatures:  Functions can have 
multiple parameter sequences, because of optional arguments with &, and 
because of complex arguments such as maps.   

2. Many functions with a base intended use are also intended to have more 
general uses.  This is particularly common for functions that are part of 
the Clojure language itself.  (What sort of intended type signatures should 
the function seq have, given that the docstring for empty? says: "Please 
use the idiom (seq x) rather than (not (empty? x))" ?)  On the other hand 
I'm sure that most functions defined outside of a general-purpose tool 
collection (such as Clojure itself) are intended *only* for very specific 
uses.  

Perhaps a syntax of such "intended-type-signatures" would be worth 
discussion in another thread.  The typed FP tradition embodied in Haskell 
may have already worked out solutions to the first set of complications, 
but not the second issue.

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

Reply via email to