<p>The type looks similar to the denotation for sets, but implementing a covariant interface for it would not be straightforward and may also be inefficient. </p>
<div class="gmail_quote">On Apr 16, 2013 11:17 AM, &quot;Alejandro Serrano Mena&quot; &lt;<a href="mailto:trupill@gmail.com">trupill@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
First of all, let me say that this work on matchers is really useful :)<br>
<br>
Following Roman advice, I&#39;m trying to find a more principled approach<br>
that could be useful for this library. It seems that &quot;Match&quot; could<br>
easily be converted to Either and thus made into Functor, Applicative,<br>
Alternative and Monad. That would allow to write things like:<br>
<br>
User &lt;$&gt; runMatch (isNot isEmpty) name &lt;*&gt; runMatch (hasItem (is &#39;@&#39;)) email<br>
<br>
However, I&#39;m also thinking about the correct way to &quot;combine&quot; matchers<br>
to get bigger matchers. Basically, if I have matchers on every field<br>
of a record, can I get a matcher for the entire one?<br>
<br>
My first idea was to make Matcher a functor. However, what I come was<br>
a contravariant functor: given (a -&gt; b) and Matcher b, I can easily<br>
construct a Matcher a by running the one in b over this function. So<br>
we have:<br>
<br>
contramap :: (a -&gt; b) -&gt; Matcher b -&gt; Matcher a<br>
<br>
My first question is: is there any structure similar to applicative<br>
functors or monads which work on these kind of contravariant functors?<br>
This also brought into my mind to see Matcher a just as functions a -&gt;<br>
Match and derive its properties from there. This may give better<br>
results that the above mentioned idea of looking it as a -&gt; Either<br>
String a, because in this latter case we have a in covariant and<br>
contravariant positions and it&#39;s difficult to get anything.<br>
<br>
On the other hand, it seems very easy, from a Matcher a and a Matcher<br>
b, to get a Matcher (a,b). This reminds me a bit about arrows, but<br>
without output parameters. Does it make sense? I&#39;ve always been<br>
reluctant to arrows because I don&#39;t fully understand them, but maybe<br>
this is a good moment to learn.<br>
<br>
Do any of this make sense? I would really like to contribute to this<br>
great library! :)<br>
<br>
2013/4/16 Tom Crayford &lt;<a href="mailto:tcrayford@gmail.com">tcrayford@gmail.com</a>&gt;:<br>
&gt; Roman,<br>
&gt;<br>
&gt; Thanks for the feedback! I&#39;d originally left the QuickCheck and HUnit<br>
&gt; implementations in this library for convenience, thinking that there aren&#39;t<br>
&gt; going to be many people who care about the transitive dep. But you care, so<br>
&gt; I&#39;m happy moving them out of core. I&#39;ll release a 0.2 with both the HUnit<br>
&gt; and the QuickCheck runners in separate libraries soonish.<br>
&gt;<br>
&gt; Thanks for the haddock tip and the implementation tips.<br>
&gt;<br>
&gt; Re the Control namespace, these matchers aren&#39;t exclusively a testing tool.<br>
&gt; I&#39;ve been using the core api for other purposes as well (primarily for<br>
&gt; validating forms in user interfaces in conjunction with digestive-functors).<br>
&gt; I couldn&#39;t figure anything better to put it in apart from Control (I<br>
&gt; definitely don&#39;t want it in Test, even though that&#39;s going to be what most<br>
&gt; people use it for). I guess it could be in `Data`, but that doesn&#39;t sound<br>
&gt; much better to me.<br>
&gt;<br>
&gt; I&#39;m not amazingly strong at building more principled interfaces right now,<br>
&gt; so I guess that&#39;s something I&#39;ll improve on. Are there any concrete<br>
&gt; suggestions you have there? I&#39;d *like* these to have an `Alternative`<br>
&gt; instance, but making `Applicative`/`Functor` instances is beyond me right<br>
&gt; now (I guess I&#39;d have to change the core API for that to work out).<br>
&gt;<br>
&gt; Tom<br>
&gt;<br>
&gt;<br>
&gt; ...<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div>