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

[ideas] providing generic functions to compare 'a against a Js.null #2410

Closed
bobzhang opened this issue Dec 27, 2017 · 0 comments
Closed

[ideas] providing generic functions to compare 'a against a Js.null #2410

bobzhang opened this issue Dec 27, 2017 · 0 comments

Comments

@bobzhang
Copy link
Member

bobzhang commented Dec 27, 2017

val eqlNull : 'a  -> box:'a Js.null -> bool 
val eqOpt : 'a -> box:'a option -> bool

note null =~ null should return true
polymorphic comparison warning should emitted when it can not be specalized

Use cases:

eqNull ~null:(Array.getNull a 0) 3 

otherwise, we have to check nullable and compare it later which is too verbose.

Do we need make use of nullary constructor?

eqOpt A ~box:v
eqNull A ~box:v

Note the option specialize is tricky:

  • when the left operand value is A, it can not be specialized A = None
  • when the left operand type is enum(not maybe_pointer), it still can not be specialized.
    it can be only specialized based on the type of first argument, given the complexity introduced, we won't do it
bobzhang added a commit that referenced this issue Dec 28, 2017
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

1 participant