Closed
Bug 1305066
Opened 8 years ago
Closed 8 years ago
Remove the Environment monad from the resolver
Categories
(L20n :: JS Library, defect)
L20n
JS Library
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: stas, Assigned: stas)
Details
(Whiteboard: [gecko-l20n])
Attachments
(1 file)
The Environment monad was modeled after the Reader monad from Haskell. It abstracts the action of passing additional arguments to each of the resolver's functions and makes it trivial to manage errors when they're returned in a [value, errors] tuple from each function. It automatically handles concatenating old errors and the new ones and makes it transparent to the developer.
In bug 1301198 we moved away from returning errors explicitly and instead we push them to an array passed as an argument. This makes the use-case for having the Environment monad less compelling. The only benefit right now is that we don't have to pass all the arguments to each function but that could be mitigated by passing a single `env` argument. OTOH, Environment adds complexity and has some performance impact, although it's only noticeable when formatting a lot of complex strings.
Let's remove it.
Assignee | ||
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
What kind of performance are we talking about?
If performance was compelling, would you prefer to keep the monad?
Updated•8 years ago
|
Flags: needinfo?(stas)
Updated•8 years ago
|
Attachment #8794227 -
Flags: review?(gandalf) → review+
Assignee | ||
Comment 3•8 years ago
|
||
No difference on workload-low, and -27% (18ms vs 13ms) on workload-high.
The monad doesn't give us much any more b/c of how we change error handling and passing an additional env object doesn't bother me too much either. It's similar to what the parser does by creating a ParseContext if you think about it.
If we ever want to go back to returning errors or choose to do something something else entirely that would benefit from this monad (or some other), we know how to do it and we can even reuse the code (which I also documented earlier today!).
Right now my votes goes to simpler codebase.
Flags: needinfo?(stas)
Assignee | ||
Comment 4•8 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•