<div dir="ltr">Adding to Kim-Ee's point,<br><br>1) When you're talking about invertible functions, the idea you're probably reaching for is an isomorphism -- that is, we want the function to have certain nice properties on top of just being a map from a -> b with an inverse map from b -> a. You also want the function to be a bijection, which is captured in the notion of an isomorphism.<br>

<br>2) Iso from Lens composes with the normal function composition operator (.) instead of rappend -- which is a little more convenient.<br><br>Arjun<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 17, 2014 at 9:28 AM, Kim-Ee Yeoh <span dir="ltr"><<a href="mailto:ky3@atamo.com" target="_blank">ky3@atamo.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi Javran,<br></div><div><br>1. Have you looked at iso lens? The lens library contextualizes isomorphisms among other interesting maps. Worth looking into.<br>

<br></div>2. Your code looks nicely idiomatic. You must have worked hard observing models of good haskell.<br>

<br></div>3. It's easy to declare at the type-level: a->b and b->a. It's just that the types don't say anything about whether they are isos or not. Whereas that's what we want.<br><br></div>Typically when I have such a pair of functions, I lean on quickcheck to give me a rapid verify as I tweak away, e.g.:<br>



<br></div><div>prop_encdecOk :: String -> Bool<br></div>prop_encdecOk xs = xs == (decode . encode $ xs)<br><div><div><div><div><div><br></div></div></div></div></div></div><div class="gmail_extra"><br clear="all"><div>



-- Kim-Ee</div>
<br><br><div class="gmail_quote"><div><div class="h5">On Mon, Mar 17, 2014 at 2:44 PM, Javran Cheng <span dir="ltr"><<a href="mailto:javran.c@gmail.com" target="_blank">javran.c@gmail.com</a>></span> wrote:<br></div>

</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">

<div dir="ltr"><div>Hi,<br><br>These days I find the notion of "inverse function" might be useful,<br>the basic idea is to keep a pair of function f and g which are the inverse functions of each other<br></div>


<div>

and then manipulate on this pair of functions.<br><br>The detail is both on my blog post:<br><br><a href="http://javran.github.io/posts/2014-03-17-capture-the-notion-of-invertible-functions.html" target="_blank">http://javran.github.io/posts/2014-03-17-capture-the-notion-of-invertible-functions.html</a><br>




</div><div><br></div><div>and also code review:<br><br><a href="http://codereview.stackexchange.com/questions/44550/capture-the-notion-of-invertible-functions" target="_blank">http://codereview.stackexchange.com/questions/44550/capture-the-notion-of-invertible-functions</a><br>




<br></div><div>I think this is an interesting idea and want to share it with you.<br>Advice and comments are welcomed and appreciated since I learn haskell through LYAH and some wiki pages<br></div><div>and still not sure about what would be the most idiomatic way of doing it in haskell.<br>




<br></div><div>Thanks,<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div><br>-- <br><div dir="ltr">Javran (Fang) Cheng<br></div>
</div></font></span></div>
<br></div></div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>