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

Maybe returns Nothing for DOM node #8

Closed
sbakht opened this issue Nov 5, 2021 · 2 comments
Closed

Maybe returns Nothing for DOM node #8

sbakht opened this issue Nov 5, 2021 · 2 comments

Comments

@sbakht
Copy link

sbakht commented Nov 5, 2021

I copied the example from the tutorial and noticed that the Maybe is Nothing for a dom node, Either works properly

console.log(L.Maybe.of(document.getElementById('app')).value) // null
console.log(L.Either.of(document.getElementById('app')).value) // dom node

See the following pen: https://codepen.io/iwanthotdog/pen/gOxeaQG

@MeetMartin
Copy link
Owner

@sbakht you are right. It is because HTML element is evaluated as empty. I will add a check for HTML and SVG elements to fix that. Thank you for the report.
Also unlike Maybe, Either doesn't have any internal check (unless you use Either.try for a function). Either is usually used as a Success or Failure output of your function.

@MeetMartin
Copy link
Owner

@sbakht this has now been fixed and your code pan works as expected
isElement and isNotElement were added to the library https://www.7urtle.com/documentation-7urtle-lambda#lambda-isElement
These affect isEmpty, which affect isNothing, which affect Maybe monad
If you find any more issues or if you have any questions, please reach out again.

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

No branches or pull requests

2 participants