<div dir="ltr">> <span style="color:rgb(0,0,0)">Maybe it should somehow replace "osiudfhg" with "x1_of", but how is it supposed to know that? It is a library function, after all.<br><br>My understanding was that the user would ask for a refactoring by explaining the isomorphism between two data types.<br><br>I just remembered that Facebook open-sourced something called Retrie that they use to refactor their own Haskell code. That should give a solid lower bound on what is possible.</span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 24, 2023 at 8:02 AM MigMit <<a href="mailto:migmit@gmail.com">migmit@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I don't think that's possible. Assume that there is a library that contains a module Stupid with a function osiudfhg, which is actually the same as fst:<br>
<br>
module Stupid where<br>
osiudfhg :: (a, b) -> a<br>
osiudfhg (a, _) = a<br>
<br>
If Alice uses that library, then her code could look like<br>
<br>
main = putStrLn "print some magic number" >> print ( osiudfhg v )<br>
<br>
How is Bob's code supposed to look? Maybe it should somehow replace "osiudfhg" with "x1_of", but how is it supposed to know that? It is a library function, after all.<br>
<br>
Yes, it might analyze source code of the Stupid module, but this is a daunting task.<br>
<br>
> On 24 May 2023, at 14:52, profited--- via Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@haskell.org</a>> wrote:<br>
> <br>
> let's consider this example<br>
> Alice has 1.hs like this<br>
> v :: (,) Int Bool<br>
> v = (,) 0 False<br>
> <br>
> main :: IO ()<br>
> main = putStrLn "print some magic number" >> print ( fst v )<br>
> <br>
> Bob download 1.hs from Alice<br>
> <br>
> Bob would like to change 1.hs to 2.hs<br>
> Bob want the programs [ 1.hs 2.hs ] to behave the same<br>
> <br>
> the reason that Bob want to modify 1.hs may be<br>
> Bob does not like the type (,) in 1.hs<br>
> <br>
> Bob has Vector_2.hs<br>
> module Vector_2 where<br>
> <br>
> data Vector_2 a b = C a b<br>
> <br>
> x1_of :: Vector_2 a b -> a<br>
> x1_of ( C x1 _ ) = x1<br>
> <br>
> x2_of :: Vector_2 a b -> b<br>
> x2_of ( C _ x2 ) = x2<br>
> <br>
> Bob like his Vector_2.hs<br>
> Bob thinks the Vector_2 shall be good enough to replace (,) in 1.hs<br>
> <br>
> i want to create a translator.hs for Bob<br>
> Bob tell the translator.hs that Bob want to replace (,) with Vector_2 in 1.hs<br>
> translator.hs automatically translate 1.hs to 2.hs<br>
> 2.hs shall look like this<br>
> import Vector_2<br>
> ( Vector_2 )<br>
> import qualified Vector_2<br>
> <br>
> v :: Vector_2 Int Bool<br>
> v = Vector_2.C 0 False<br>
> <br>
> main :: IO ()<br>
> main = putStrLn "print some magic number" >> print ( Vector_2.x1_of v )<br>
> <br>
> what shall i do ?<br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Jeff Brown | Jeffrey Benjamin Brown</div><div dir="ltr"><a href="https://www.linkedin.com/in/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">LinkedIn</a><span style="font-size:12.8px"> </span><span style="font-size:12.8px">|</span><span style="font-size:12.8px"> </span><a href="https://github.com/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">Github</a> | <a href="https://twitter.com/carelogic" target="_blank">Twitter</a> | <a href="https://www.facebook.com/mejeff.younotjeff" style="font-size:12.8px" target="_blank">Facebook</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>