haskell / haskell/haskell-mode
Alignment doesn't understand QualifiedDo
- Dominant language
- Emacs Lisp
- Stars
- 1.4k
- Forks
- 354
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
haskell mode does not recognize `QualifiedDo` notation and gets alignment wrong.
The following simple example, from the [Qualified Do user guide](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/qualified_do.html), should align like
```
{-# LANGUAGE QualifiedDo #-}
import qualified Some.Module.Monad as M
action :: M.SomeType a
action = M.do x <- u
res
M.return x
```
But haskell-mod aligns it as
```
{-# LANGUAGE QualifiedDo #-}
import qualified Some.Module.Monad as M
action :: M.SomeType a
action = M.do x <- u
res
M.return x
```
Probably thinking that `M.do` is a function, and not special notation.
It currently accepts the following alignment which also parses correctly, but looks ugly.
```
action :: M.SomeType a
action =
M.do
x <- u
res
M.return x
```
Furthermore, since the notation is not recognized, it will get confused with other multi-line notation, like list. Such as in the following example, which Haskell mode will align to configurations that don't parse.
```
action :: M.SomeType a
action =
M.do
x <- u
fooList
[ M.do
res1
, M.do
res2
]
M.return
```
Contributor guide
Research direction
Start by locating haskell-mode's alignment entry point for do notation and compare it with handling of qualified constructs such as M.do. Reproduce the examples from the issue, including the nested list case, and confirm that aligned output remains valid Haskell and matches the shown layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs, emacs-lisp, haskell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100