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

Enhance == operator to support more types #2

Open
yurtsiv opened this issue Sep 28, 2020 · 6 comments
Open

Enhance == operator to support more types #2

yurtsiv opened this issue Sep 28, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@yurtsiv
Copy link
Owner

yurtsiv commented Sep 28, 2020

Currently == only works on integers.
We need to implement it for each existing type and it should always compare by value.

Semantics

# True

1 == 1
"" == ""
"Hi" == "Hi"
[] == []
[1,2,3] == [1,2,3]
True == True

# False

1 == 0
" " == ""
"Hi" == "HI"
True == False

# Invalid (can't compare functions and can only compare values of the same type)

let func = (x) do
  x
end

func == func
[1, 2, func] == [1, 2, func]
1 == ""
1 == []
1 == True
"Hi" == ["H", "i"]
# etc...

EDIT:

Since /= is already implemented, we should make it work too

@yurtsiv yurtsiv added hacktoberfest hacktoberfest enhancement New feature or request labels Sep 28, 2020
@siddhantrao23
Copy link

Hey! I'd love to work on this. I went through the code base and the majority of changes should be made in interpreter/eval.hs, any further directions you could provide would be really helpful.

@yurtsiv
Copy link
Owner Author

yurtsiv commented Oct 3, 2020

Hi @siddhantrao23,

Yes, you're right. The exact place is where -- TODO: compare all primitive types is located.

I'd recommend adding tests first (test/Interpreter/EvalSpec.hs) and then gradually implementing the functionality.

stack test --file-watch is really handy in this case

Thank you!

@yurtsiv
Copy link
Owner Author

yurtsiv commented Oct 3, 2020

@siddhantrao23 Description is updated slightly

@yurtsiv yurtsiv removed the hacktoberfest hacktoberfest label Oct 3, 2020
@siddhantrao23
Copy link

Thanks! I'll start working on it now

@siddhantrao23
Copy link

hey @yurtsiv My exams came up so I didn't get to work on this! If there are others, do go ahead. I will contribute after my exams.

@yurtsiv
Copy link
Owner Author

yurtsiv commented Oct 17, 2020

@siddhantrao23 Hi! No problem 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants