Consider the way
core.typedannotates a function:(t/ann typed-function [t/Str :-> t/Str])Now consider the way Prismatic Schema annotates a function:
(s/defn schema-function :- s/Str [arg :- s/Str] arg)
Personally, I find the way that core.typed annotates a function be much clearer and closer in spirit to strongly typed languages like Haskell.
Question: Is there a way to make some sort of macro or function in clojure with Prismatic Schema that has the effect of (2) but the visual appearance of (1)? That is, something like the following:'
(custom-annotation-macro schema-function [s/Str :-> s/Str])
(defn schema-function [arg] arg)
such that the effect is merely just
(s/defn schema-function :- s/Str
[arg :- s/Str]
arg)
To illustrate how you could solve this with two macros:
I haven't bothered to implement
split-fun-typebecause I don't really know Clojure; the above is based on my understanding that it's a Lisp.