[Haskell-cafe] Haskell syntax/indentation for vim

Dan Doel dan.doel at gmail.com
Tue Mar 5 01:55:10 CET 2013


They're hard to come by, but some other examples might be...

1) If you type something that is recognizably a guard, it could pop
back other guards:

    foo x y z
      | guard1 = do ...
                    | guard2 = -- outdent now

Not sure how feasible that one is.

2) When you type 'else', outdent to the same indentation as the
associated 'then'.

There may be others, but those are what I could think of after a few
minutes of pondering.


On Mon, Mar 4, 2013 at 12:40 PM, Tristan Ravitch <travitch at cs.wisc.edu> wrote:
> I like automatic "outdenting" too, but I only came up with three cases
> where I felt like I could do it reliably:
>
>  * With let/in as you described
>  * After a catchall case:
>
>    case ... of
>      C1 -> ...
>      C2 -> ...
>      _ -> ...
>    -- dedent back to here
>
>  * And similarly after a do block ending in a return
>
> Even that last one is slightly questionable, I feel, but probably works
> for almost all cases.  Are there any others?
>
> On Mon, Mar 04, 2013 at 12:20:12PM -0500, Dan Doel wrote:
>> I hadn't seen this before, but I tried it out, and the parts I'm interested
>> in are nice. The indenting is less flaky than what I was using before
>> (comments had issues).
>>
>> If you're rewriting things, though, it'd be nice to be able to customize
>> indentation a little more. For instance, I like laying out ifs like:
>>
>>     if foo
>>       then bar
>>       else baz
>>
>> But I like to lay out wheres as:
>>
>>     foo = ...
>>      where
>>      bar = ...
>>
>> But both the indents here are based on shiftwidth, so they're tied together.
>>
>> Another 'nice to have' would be some intelligent outdenting. For instance,
>> if you type a let block right now:
>>
>>     let foo = zig
>>         bar = zag
>>         in ...
>>
>> That's what you'll get. It'd be nice if typing the 'in' snapped back to the
>> let. I know it's possible to implement something like this, because the
>> scala indentation mode I use frequently outdents when I type '=>' (which
>> annoys the hell out of me, because it's almost never correct), but I don't
>> know if it can be done intelligently enough to be useful (which would be
>> important). Something to keep in mind, though.
>>
>> -- Dan
>>
>>
>> On Sun, Mar 3, 2013 at 9:48 AM, dag.odenhall at gmail.com <
>> dag.odenhall at gmail.com> wrote:
>>
>> > I see now in your README that you have seen vim2hs.  I'd love to hear what
>> > you disliked about it, especially given my plan to rewrite the whole thing
>> > [1]! :)
>> >
>> > [1] https://github.com/dag/vim2hs/issues/45
>> >
>> >
>> > On Sun, Mar 3, 2013 at 3:38 PM, dag.odenhall at gmail.com <
>> > dag.odenhall at gmail.com> wrote:
>> >
>> >> Hi
>> >>
>> >> Have you seen vim2hs?
>> >>
>> >> https://github.com/dag/vim2hs
>> >>
>> >>
>> >> On Sat, Mar 2, 2013 at 9:11 PM, Tristan Ravitch <travitch at cs.wisc.edu>wrote:
>> >>
>> >>> Cafe,
>> >>>
>> >>> I've recently been playing with vim and wasn't quite satisfied with the
>> >>> existing syntax highlighting and indentation, so I thought I'd try my
>> >>> hand at a new Haskell mode:
>> >>>
>> >>> https://github.com/travitch/hasksyn
>> >>>
>> >>> It is minimal in that it doesn't provide support for running external
>> >>> commands over code or anything fancy.  It just does syntax highlighting
>> >>> and reasonably-smart indentation.  There is no support for literate
>> >>> Haskell since supporting both with one mode is very tricky.
>> >>>
>> >>> It might be useful to some people.  Comments, bug reports, and
>> >>> suggestions
>> >>> welcome.
>> >>>
>> >>> _______________________________________________
>> >>> Haskell-Cafe mailing list
>> >>> Haskell-Cafe at haskell.org
>> >>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >>>
>> >>>
>> >>
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>> >



More information about the Haskell-Cafe mailing list