Constructor from a multi-constructor type can't be conveniently passed as parameter #711
KristianBalaj
started this conversation in
Core language features
Replies: 1 comment
-
Please start using discussions for this kind of thing. But definitely a cool idea. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is your idea? Provide a use case.
Having the following code is not possible:
There should be some way how to pass the data as a single parameter so it can be conveniently used in a function.
Why is it a good idea?
A single constructor types can be easily passed as parameters and then used for e.g. record updates using the
..
operator. Record updates have to list all the fields one by one becoming too error prone.Also such datum can be used using a dot access without any unnecessary verbosity.
What is the current alternative and why is it not good enough?
Data
can be passed and then used withexpect
to match the constructor again - it's a little more convenient as 1. but still convenient record updates are not possible.So there's no cool way of achieving this AFAIK.
E.g. PureScript has a nice solution to this, it can pass the parameters as an object
{..}
aliased with some type and a spread operator can be used for record updates.Beta Was this translation helpful? Give feedback.
All reactions