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
Dot notation for "Methods" #2282
Comments
Thanks for reporting this! To set expectations:
Finally, please be patient with the core team. They are trying their best with limited resources. |
Some discussion here: https://discourse.elm-lang.org/t/dot-notation-for-methods/8727 |
I did not read the discussion on discourse so apologizes if I'm repeating something from there. With this proposal I wonder what you would expect for this code to produce: adding_one t =
t.map (\a -> a + 1) My takeI can imagine primarily 2 expected results... Ad-hoc PolymorphismThis code should compile and work so that I can call: adding_one (Just 1)
--> Just 2
adding_one [1, 2, 3]
--> [2, 3, 4] Anyway as you can see this introduces new type of polymorphism which is currently not possible in elm. The type would be something like: adding_one : f Int -> f Int where This Code should be rejectedCompiler should error with something adding_one : Maybe Int -> Maybe Int Anyway as you can see this syntax would break type inference in a way it would no longer be possible to infer type without this annotation. Also in my opinion this makes whole feature kind of useless. It would make adding_one f =
f |> Maybe.map ((+) 1) |
I think adding a function "method" dot notation would simplify expressions and ease adaptation for JS-developers.
Lean4 is purely functional, but also has support for .dot notation for associated functions. https://leanprover.github.io/lean4/doc/namespaces.html
I think this should be added to Elm too.
Example
The text was updated successfully, but these errors were encountered: