Skip to content

[Discussion] Make haskell-indentation external, editor agnostic project #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arybczak opened this issue Jan 16, 2016 · 5 comments
Closed

Comments

@arybczak
Copy link

Hey,

I've recently realized that even though haskell-indentation has seen a lot of improvements recently and is quite pleasant to use, there are two fundamental problems:

  1. It's emacs specific, so it doesn't benefit anyone who is not an emacs user.
  2. It's written in elisp, which creates high entry barrier for newcomers who would want to contribute.

Both of these severely reduce the pool of people who would be willing to improve the state of the project. Therefore I wonder if we could benefit from porting haskell-indentation to other language (Haskell seems to be the obvious choice here) and making it an external application so that editors can just pass the code and receive a list of possible indentations to use.

Any thoughts?

@gracjan gracjan changed the title [Proposal/discussion] Make haskell-indentation external, editor agnostic project [Discussion] Make haskell-indentation external, editor agnostic project Jan 16, 2016
@geraldus
Copy link
Contributor

I had some similar thoughts, however, Emacs provide a way to package authors control various aspects of Emacs behaviour such as indentation, pairs, completions via special variables, e.g. indent-line-function, completion-at-point-function and etc. Surely, if you design some major mode you could rely on Emacs default behaviour, but if there is a way to customize this stuff why not to do this?

One thing I can say for sure we can not depend on any external tool, haskell-mode should be self-sufficient.

There is very promising Haskell IDE Engine project and if indentation stuff will be added to it, we could use HIE to handle indentation, but even in this case it should be optional and it would be great to provide some fallback. I think future of HIE is still unclear for now, it may or may not become tool number one for any kind of Haskell workflow. Even if we remove indentation logic from haskell-mode we should have some handy customizations.

One last point, when I started contributing to haskell-mode I had 0 experience in Elisp, but it was super easy to learn it. I think what we really need is greater number of active people involved in process, I think there are many things we can improve and simplify and make haskell-mode more qualitative and outstanding.

@gracjan
Copy link
Contributor

gracjan commented Jan 16, 2016

@arybczak: Possible and doable although a lot of work.

Note also that indentation has a couple of unintuitive requirements:

  • has to work for invalid haskell code (basically any stream of bytes)
  • has to support haskell, haskell+cpp, literate haskell, hsc, all future versions of haskell, etc
  • has to not fail if source code has git conflict markers
  • there are things like hsx, layers on top of haskell
  • there is already rich and growing set of quasi quote languages (sql, yesod, etc)

There are projects like structured-haskell-mode and ghc-exactprint, but those work only with syntactically correct Haskell source files.

@arybczak
Copy link
Author

@geraldus

Surely, if you design some major mode you could rely on Emacs default behaviour, but if there is a way to customize this stuff why not to do this?

Can you provide an example of limitation arising from having indentation helper as external application? My understanding is that if you treat the helper as referentially transparent function, i.e. you pass a config and a fragment of Haskell code and you get a list of indentation points, you're good. A conversion from haskell-mode config to helper config would be needed, but that is not a problem.

One thing I can say for sure we can not depend on any external tool, haskell-mode should be self-sufficient.

That is a noble goal, but it creates unnecessary duplication of work. How many editor developers had (and will have) to do the same thing over and over again to get indentation in Haskell to somehow work?

I've looked at HIE, but I don't think there are currently any efforts to solve this specific problems so far.

@gracjan

Yes, these requirements make it quite challenging as this prevents us from reusing any existing parser library like haskell-src-exts, unless one makes it return partial syntax tree in case of errors and also contain information about indentation of the source code.

Quasi-quoters are a whole issue altogether, but this could possibly be solved e.g. by custom plugins written by their authors or something.

Ultimately the same set of issues applies no matter if the development of indentation-mode continues in Elisp for Emacs only or as the external, editor agnostic application, but I would think that the probability of these problems getting solved is much higher in case of the latter.

@geraldus
Copy link
Contributor

@arybczak if such helper indentation application will support all possible platforms suitable for Haskell+Emacs workflow I guess this won't be an issue.

@gracjan
Copy link
Contributor

gracjan commented Jan 31, 2016

I guess the following holds true:

  • external indentation tool is not going to happen under Haskell Mode umbrella due to lack of manpower
  • if such tool appears we will be eager to support it

I'll close this ticket. Please reopen if you have such a tool running :)

@gracjan gracjan closed this as completed Jan 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants