use
can be quite confusing
#2146
Replies: 3 comments 10 replies
-
Better error messages are something we want for sure! Currently it's syntactic sugar, in future we're likely to have a dedicated compile path for it.
What did you have in mind?
If you use the version of Gleam that deprecated |
Beta Was this translation helpful? Give feedback.
-
I'm not clear what happens when you do
Could this maybe be allowed by tweaking operators precendence, is there such a thing in Gleam? |
Beta Was this translation helpful? Give feedback.
-
| What did you have in mind? I don't have any good ideas at the moment. I was looking at how OCaml where they have several keyword/operators combinations like I was also looking at Unison abilities, where you can define your handlers. Something like defining your own But given that Result is such a common return value, maybe it could be priviliged in the language again, like it was with
|
Beta Was this translation helpful? Give feedback.
-
I really like the concept of
use
as a way to have a general way to reduce nesting and boilerplate.However I was just upgrading a library (removing try). And I found
use
quite confusing to use.Here are common errors I hit:
Common error 1 - forgetting to use result.then
The error for
use
is puzzling because you cannot see the unwanted extra argument in that line.Common error 2 - using pipe
As is common to use pipes everywhere, this ^ makes a lot of sense
This error is also very hard to understand as there are lot of types involved.
The proper way is
try
was quite straightforward, but unfortunatellyuse
is not. You really need to understand what is going on, it is quite hard to figure it out from the errors.So ideas
Beta Was this translation helpful? Give feedback.
All reactions