haskell / haskell/alex

Allow custom error types in monad wrappers

Open
#178 8 comments 7 reactions 0 assignees View on GitHub
feature request wrapper
Dominant language
Haskell
Stars
323
Forks
87
PR merge metrics
No merged PRs in 30d

Description

I want to extract the position information on lexing errors so I can send them to an LSP client, but the error type for the wrappers is hard coded to be string, so it is difficult to send along that extra information.
As far as I can tell, the change would mostly consist of replacing `Either String a` with `Either err a`, adding a corresponding type parameter to `Alex a` and adjusting the line
```
AlexError ((AlexPn _ line column),_,_,_) -> alexError $ "lexical error at line " ++ (show line) ++ ", column " ++ (show column)
```

1. Is there an easier way to do this?
2. Am I missing some problems with this approach?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.