<div dir="ltr"><font face="monospace, monospace">Well, it seems such a wrapper for Pikaday has been written in another functional front-end language: ClojureScript.</font><div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">In April 2015 somebody wrote a ClojureScript wrapper for the Pikaday JavaScript datepicker library:<br></font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <a href="https://timgilbert.wordpress.com/2015/04/03/i-wrote-a-thing/">https://timgilbert.wordpress.com/2015/04/03/i-wrote-a-thing/</a><br></font></div></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Actually this implementation of a Pikaday wrapper is dependent not only on:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- ClojureScript; but also on </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- Reagent - which is one of the leading ClojureScript wrappers for Facebook React</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Notes:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(1) I found Pikaday by googling [minimal javascript datepicker]. Pickaday does not have any dependencies on other JavaScript libraries, and it says it uses "modular" CSS.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(2) The author of this Reagent-based ClojureScript Pikaday wrapper says that, later on, other implementations of this ClojureScript Pikaday wrapper are also planned, which would be based on other leading ClojureScript wrappers for Facebook React such as:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- Om; and </font></div><div><font face="monospace, monospace">- re-frame<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The fact that this ClojureScript Pikaday wrapper is based on a ClojureScript React wrapper is probably a *good* thing. </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">For 2 reasons:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(a) It probably makes its syntax and semantics even *closer* to those of Ur/Web </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(b) It abstracts away from the React library code - which would be redundant in Ur/Web anyways.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Implementation:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Apparently the main thing this ClojureScript Pikaday wrapper involves is a function with three 'if'-statements which set three fields in the argument record passed to the Pikaday object-instantiation function in JavaScript:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <a href="https://github.com/timgilbert/cljs-pikaday/blob/master/src/cljs_pikaday/reagent.cljs">https://github.com/timgilbert/cljs-pikaday/blob/master/src/cljs_pikaday/reagent.cljs</a><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It makes sense that this would be the main thing this function would do - and I guess it directly addresses my question earlier in this thread:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">>     <span style="color:rgb(0,0,0);white-space:pre-wrap">val aPikaday : ??? -> transaction unit</span></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="color:rgb(0,0,0);white-space:pre-wrap">> (2) The function aPikaday in file pikaday.js [*] takes an argument called </span><span style="color:rgb(0,0,0);white-space:pre-wrap">'options'.</span></font></div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="monospace, monospace">> What is the *type* of this argument (to insert above, where the '???' is)?</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="monospace, monospace">[*] Originally this file was named 'Pikaday'. I changed it to 'aPikaday' to make it a valid Ur/Web 'val' identifier.</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="monospace, monospace">---</font></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><font face="monospace, monospace">Now I imagine that an Ur/Web wrapper for the Pikaday library could be more easily developed by using this ClojureScript wrapper for the Pikaday library as a guide.</font></pre></div><div><font face="monospace, monospace">Confession:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Most JavaScript libraries have been unintelligible to me - as a code-reading exercise. I've printed out shorter libraries which I thought were compact and important enough to learn, and Istared at them for hours - and I just never know what's what. </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It's always some factory returning a factory which returns some anonymous function which contains a bunch of functions - and I just never can figure out how I could call these functions-inside-a-function-inside-a-factory-inside-a-factory via an FFI (foreign-function interface).</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Hope:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">But I can understand a ClojureScript (and CoffeeScript, etc.) library - and it seems to directly suggest a similar (and probably much shorter!) implementation in a language such as Ur/Web. </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I hope I can jump directly from being someone who can't even read most JavaScript libraries - to being someone who can wrap one in Ur/Web - at least when initially given a ClojureScript wrapper of the same JavaScript library.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">###</font></div><div><br></div></div>