Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell - Expectativa Uses: no detecta usos en record syntax #336

Open
asanzo opened this issue May 10, 2021 · 3 comments · May be fixed by #337
Open

Haskell - Expectativa Uses: no detecta usos en record syntax #336

asanzo opened this issue May 10, 2021 · 3 comments · May be fixed by #337

Comments

@asanzo
Copy link
Collaborator

asanzo commented May 10, 2021

¡Buenas!

Esta solución para este desafío tira como que no usa la función cuantoLePuedeDar y sí la usa.

cuantoLePuedeDar auto1 auto2 = min (nivelNafta auto1) (tamanioTanque auto2 - nivelNafta auto2)

transferir :: Auto -> Auto -> (Auto,Auto)
transferir auto1 auto2 = (auto1 {nivelNafta = (nivelNafta auto1) - cuantoLePuedeDar  auto1 auto2}, auto2 {nivelNafta = (nivelNafta auto2) + cuantoLePuedeDar auto1 auto2})

image

image

¿Tendrá algo que ver con que esté dentro de un constructor con record syntax?

@asanzo
Copy link
Collaborator Author

asanzo commented May 10, 2021

Estuve jugando un ratito.

La última línea de ese código, que aparentemente parsea a algo así como:

(HsIdent "transferir") [HsPVar (HsIdent "auto1"),HsPVar (HsIdent "auto2")] (HsUnGuardedRhs (HsTuple [HsRecUpdate (HsVar (UnQual (HsIdent "auto1"))) [HsFieldUpdate (UnQual (HsIdent "nivelNafta")) (HsInfixApp (HsParen (HsApp (HsVar (UnQual (HsIdent "nivelNafta"))) (HsVar (UnQual (HsIdent "auto1"))))) (HsQVarOp (UnQual (HsSymbol "-"))) (HsApp (HsApp (HsVar (UnQual (HsIdent "cuantoLePuedeDar"))) (HsVar (UnQual (HsIdent "auto1")))) (HsVar (UnQual (HsIdent "auto2")))))],HsRecUpdate (HsVar (UnQual (HsIdent "auto2"))) [HsFieldUpdate (UnQual (HsIdent "nivelNafta")) (HsInfixApp (HsParen (HsApp (HsVar (UnQual (HsIdent "nivelNafta"))) (HsVar (UnQual (HsIdent "auto2"))))) (HsQVarOp (UnQual (HsSymbol "+"))) (HsApp (HsApp (HsVar (UnQual (HsIdent "cuantoLePuedeDar"))) (HsVar (UnQual (HsIdent "auto1")))) (HsVar (UnQual (HsIdent "auto2")))))]])) []]]

Tiene constructores como HsRecUpdate (y dentro de él HsFieldUpdate) que no estarían siendo considerados acá:

https://github.com/mumuki/mulang/blob/master/src/Language/Mulang/Parsers/Haskell.hs

Y ya que estamos, creo que tampoco está construyendo el árbol para HsRecConstr, que según lo que veo acá serían los constructores por record syntax como UnAuto {nafta = 100}.

No sé si cargar el issue en Mulang. @julian-berbel @flbulgarelli Lo cargo ahí?

Tampoco sabría definir a qué debería parsear eso.

@augusleca
Copy link

Gracias por la ayuda Alf! Muy interesante

@julian-berbel
Copy link
Member

👋 efectivamente este issue pertenece en mulang!

@julian-berbel julian-berbel transferred this issue from mumuki/mumuki-laboratory May 10, 2021
@julian-berbel julian-berbel linked a pull request Jun 17, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants