I like languages that are readable. This is starting to look like codegolf. https://github.com/reasonml-community/reason-react-hacker-ne...
I like languages that are readable. This is starting to look like codegolf. https://github.com/reasonml-community/reason-react-hacker-ne...
I think you'll find that any code that deals with foreign function interfaces and interop with the host environment is ugly in any language.
EDIT:
Sorry, I just don't like when people share shallow and negative thoughts about projects that take away from meaningful discussion.
Why is the OP comment shallow? Because obviously _some_ people find it readable which would suggest that it is familiarity that is the problem -- not some universal quality of the language.
You're not constrained to use one-letter names for type variables, or to drop names of argument variables, but it turns out to be very handy, and it only takes reading a couple of hundred lines of code to get comfortable with this notation.
It scales easier to settle the debate by just fulfilling the demand rather than encountering each such argument and spend literally years debating about them.
Are you more like a dev-advocat or something?
Anyways, since I'm basically doing Reason 24/7 I kinda consider myself to be on the team.
My guess in this case is that get_internal is a function that receives two parameters (a map with keys of type `a` and values of type `b`, and a key of type `a`) and returns a value of type `b` or `undefined`, if the key is missing. The return is wrapped in an option type so you don't mix the `b`s with the `undefined`s.
That said, this is a very weird example to pick because the actual implementation of the function is not in this file. Assuming that in Reason the @@ means the same as in Ocaml, that `@@` is placeholder that tells the code preprocessor where to insert the actual code for the implementation of `get`. The actual logic for the get function would be in the preprocessor.
Where's the documentation for this? I'm only familiar with `@@` as a low-precedence no-op operator which helps to cut down on parentheses.
https://whitequark.org/blog/2014/04/16/a-guide-to-extension-... https://blog.janestreet.com/extension-points-or-how-ocaml-is...
These can be used to do the sort of metaprogramming that people used to do with camlp4. If you want to search more, the other keyword for googling would be "ppx".
* "external" is an FFI declaration
* "get_internal" is the local symbol name
* ":" introduces the type signature, so "get_internal" is a function from a "map 'a 'b" (aka Map<A, B> in more C-style generics) and an 'a to a Js.undefined 'b
* followed by the external symbol ("get")
* and the stuff between brackets is a compiler instruction (an "extension point": https://whitequark.org/blog/2014/04/16/a-guide-to-extension-...)
from https://github.com/reasonml-community/Mareo/blob/master/src/...
ignore, in OCaml, allows to "cast the expression to void"
val ignore : 'a -> unit
it just discards the value it is given."@@" is a low-binding application operator, similar to Haskell's "$", it's used to avoid parenthesising.