lexical-lsp / vscode-lexical

VSCode extension for Lexical, the modern Elixir language server
Apache License 2.0
36 stars 6 forks source link

Adopt functional error management #11

Open Blond11516 opened 1 year ago

Blond11516 commented 1 year ago

Errors are currently handled through the use of exceptions. Because Elixir is a functional language, I think it would make contributions easier if they were handled in a manner more similar to what elixir developers are used to.

I would suggest using a result monad, since pattern matching on tuples doesn't have great support in Javascript.

Will have to investigate whether to write this monad manually or import a functional programming dependency.

Blond11516 commented 1 year ago

Thinking more about this, monads probably aren't the best idea because Elixir developers aren't really used to the concept.

Errors are rather usually handled through pattern matching, with and the like. Pattern matching isn't available in javascript, so some more thought will be required to find something that matches the Elixir experience as closely as possible.

scottming commented 1 year ago

You can take a look at the fp.ts, I used it before, its awesome.