<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, "Alejandro Serrano Mena" <<a href="mailto:trupill@gmail.com">trupill@gmail.com</a>> 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'm trying to find a more principled approach<br>
that could be useful for this library. It seems that "Match" 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 <$> runMatch (isNot isEmpty) name <*> runMatch (hasItem (is '@')) email<br>
<br>
However, I'm also thinking about the correct way to "combine" 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 -> 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 -> b) -> Matcher b -> 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 -><br>
Match and derive its properties from there. This may give better<br>
results that the above mentioned idea of looking it as a -> Either<br>
String a, because in this latter case we have a in covariant and<br>
contravariant positions and it'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've always been<br>
reluctant to arrows because I don'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 <<a href="mailto:tcrayford@gmail.com">tcrayford@gmail.com</a>>:<br>
> Roman,<br>
><br>
> Thanks for the feedback! I'd originally left the QuickCheck and HUnit<br>
> implementations in this library for convenience, thinking that there aren't<br>
> going to be many people who care about the transitive dep. But you care, so<br>
> I'm happy moving them out of core. I'll release a 0.2 with both the HUnit<br>
> and the QuickCheck runners in separate libraries soonish.<br>
><br>
> Thanks for the haddock tip and the implementation tips.<br>
><br>
> Re the Control namespace, these matchers aren't exclusively a testing tool.<br>
> I've been using the core api for other purposes as well (primarily for<br>
> validating forms in user interfaces in conjunction with digestive-functors).<br>
> I couldn't figure anything better to put it in apart from Control (I<br>
> definitely don't want it in Test, even though that's going to be what most<br>
> people use it for). I guess it could be in `Data`, but that doesn't sound<br>
> much better to me.<br>
><br>
> I'm not amazingly strong at building more principled interfaces right now,<br>
> so I guess that's something I'll improve on. Are there any concrete<br>
> suggestions you have there? I'd *like* these to have an `Alternative`<br>
> instance, but making `Applicative`/`Functor` instances is beyond me right<br>
> now (I guess I'd have to change the core API for that to work out).<br>
><br>
> Tom<br>
><br>
><br>
> ...<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>