[Haskell-cafe] what are correct ways to translate haskell code ?
Jeffrey Brown
jeffbrown.the at gmail.com
Wed May 24 12:57:34 UTC 2023
The term for this is "automatic refactoring". It's a deep problem, but it's
been written about a lot.
On Wed, May 24, 2023 at 7:53 AM profited--- via Haskell-Cafe <
haskell-cafe at haskell.org> wrote:
> let's consider this example
> Alice has 1.hs like this
> v :: (,) Int Bool
> v = (,) 0 False
>
> main :: IO ()
> main = putStrLn "print some magic number" >> print ( fst v
> )
>
> Bob download 1.hs from Alice
>
> Bob would like to change 1.hs to 2.hs
> Bob want the programs [ 1.hs 2.hs ] to behave the same
>
> the reason that Bob want to modify 1.hs may be
> Bob does not like the type (,) in 1.hs
>
> Bob has Vector_2.hs
> module Vector_2 where
>
> data Vector_2 a b = C a b
>
> x1_of :: Vector_2 a b -> a
> x1_of ( C x1 _ ) = x1
>
> x2_of :: Vector_2 a b -> b
> x2_of ( C _ x2 ) = x2
>
> Bob like his Vector_2.hs
> Bob thinks the Vector_2 shall be good enough to replace (,) in 1.hs
>
> i want to create a translator.hs for Bob
> Bob tell the translator.hs that Bob want to replace (,) with
> Vector_2 in 1.hs
> translator.hs automatically translate 1.hs to 2.hs
> 2.hs shall look like this
> import Vector_2
> ( Vector_2 )
> import qualified Vector_2
>
> v :: Vector_2 Int Bool
> v = Vector_2.C 0 False
>
> main :: IO ()
> main = putStrLn "print some magic number" >> print (
> Vector_2.x1_of v )
>
> what shall i do ?
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
--
Jeff Brown | Jeffrey Benjamin Brown
LinkedIn <https://www.linkedin.com/in/jeffreybenjaminbrown> | Github
<https://github.com/jeffreybenjaminbrown> | Twitter
<https://twitter.com/carelogic> | Facebook
<https://www.facebook.com/mejeff.younotjeff>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20230524/d698f3bb/attachment.html>
More information about the Haskell-Cafe
mailing list