gregsexton / origami.el

A folding minor mode for Emacs
515 stars 41 forks source link

Please add haskell support #35

Open meditans opened 8 years ago

meditans commented 8 years ago

It would be great to have a simple solution for haskell folding. The current solution, based on indentation, has many of the problems already highlighted in the python issue. Is there an example parser from where I could start?

vyp commented 8 years ago

It would be nice to be able to fold up function definitions to just their type annotation line (if they have it), as a thought.

meditans commented 8 years ago

@vyp the current behaviour does that, if the type annotation is preceded by a blank line. My main problem with this indentation is that if there is a haddock comment in the lines directly above the signature, the code gets folded to the first line of the haddock.

vyp commented 8 years ago

Ah I see! I haven't actually used origami yet! (soon) So I assumed it didn't work with haskell at all because of this ticket.. :expressionless:

gregsexton commented 8 years ago

Take a look at the parsers in https://github.com/gregsexton/origami.el/blob/master/origami-parsers.el

The problem with Haskell is that there isn't a keyword used when defining a function, so this may be tricky. Unless you're willing to write an elisp Haskell parser (which would be cool) or one already exists (I have no idea), then you're probably left with adding some heuristics to the indentation parser. Maybe you could generalise this so we can add python support easily. Then the python guys will stop harassing me and I will be forever in your debt. :)

I'll try and help out with specific questions as much as possible.

wbolster commented 6 years ago

with #69 and haskell-mode, the example code from https://hackage.haskell.org/package/base-4.11.0.0/docs/src/Data.Foldable.html looks like this:

image