[Haskell-beginners] Capture the notion of invertible functions
Kim-Ee Yeoh
ky3 at atamo.com
Mon Mar 17 13:28:35 UTC 2014
Hi Javran,
1. Have you looked at iso lens? The lens library contextualizes
isomorphisms among other interesting maps. Worth looking into.
2. Your code looks nicely idiomatic. You must have worked hard observing
models of good haskell.
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.
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.:
prop_encdecOk :: String -> Bool
prop_encdecOk xs = xs == (decode . encode $ xs)
-- Kim-Ee
On Mon, Mar 17, 2014 at 2:44 PM, Javran Cheng <javran.c at gmail.com> wrote:
> Hi,
>
> These days I find the notion of "inverse function" might be useful,
> the basic idea is to keep a pair of function f and g which are the inverse
> functions of each other
> and then manipulate on this pair of functions.
>
> The detail is both on my blog post:
>
>
> http://javran.github.io/posts/2014-03-17-capture-the-notion-of-invertible-functions.html
>
> and also code review:
>
>
> http://codereview.stackexchange.com/questions/44550/capture-the-notion-of-invertible-functions
>
> I think this is an interesting idea and want to share it with you.
> Advice and comments are welcomed and appreciated since I learn haskell
> through LYAH and some wiki pages
> and still not sure about what would be the most idiomatic way of doing it
> in haskell.
>
> Thanks,
>
> --
> Javran (Fang) Cheng
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140317/ce1c0786/attachment.html>
More information about the Beginners
mailing list