On Thu  1 May 2014 at 09:05:29AM -0700, Mars0i wrote:

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

Schema expresses these scenarios quite well, as does core.typed AFAIK.

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

Constraining inputs to those that satisfy protocols and interfaces goes
a long way, and provides considerable flexibility, while still providing
meaningful constraints.

Have a function that uses `slurp` or `spit` on a parameter? Declare that
the parameter satisfies clojure.java.io/Coercions.

Have a function that expects any kind of map-like object that supports
`get`? Declare that it must satisfy clojure.lang.Associative.

And so on. Together with Java type hierarchies, I have found it quite
easy to declare polymorphic function signatures using Schema.

    guns

Attachment: pgpbQdkXAUa7G.pgp
Description: PGP signature

Reply via email to