Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-08 Thread Claus Reinke


something like the attached vim script might work for small sources
(ignores all layout rules and keywords, just records increase/decrease 
of indentation stack; builds up a rather large pattern of positions for

highlighting via :match).

(don't assume that this is the only, let alone the right way to do this,
and please pardon my rusty vimscript;-)

bonus tasks are left as exercises for the reader..

Claus

ps. a good interface for teaching vim about language syntax and 
   motion would be nice (or at least a dynamically loadable, 
   position-independent GHC API for use with vim's libcall..), 
   but I find that with visual highlighting of lines and blocks, Haskell 
   layout manipulation at least tends to be fairly straightforward

   (I do not even use highlightling of the cursor column, which gives
   you a vertical ruler)

- Original Message - 
From: "Donald Bruce Stewart" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, December 07, 2006 12:34 AM
Subject: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs



I'd like some more help from the editors in getting 2d layout right
without trying. Here's a mockup of vim with vertical grey bars
delimiting layout:

   http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png

Does anyone know how to get this effect in vim (or emacs)?

Bonus points if the grey bars are draggable, changing the indenting.
More bonus points for box-based navigation.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

blocks.vim
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread John Meacham
On Wed, Dec 06, 2006 at 05:37:01PM -0800, Carl Witty wrote:
> On Wed, 2006-12-06 at 16:56 -0800, John Meacham wrote:
> > Having played with haskell parsers for various reasons, the layout rule
> > is quite tricky due to the rules involving 'parse-error'. if we could
> > come up with a formulation that didn't have those. it would make things
> > a whole lot nicer. something like an unexpected 'in', 'of', ')' '}'
> > ']' might  do it. the lexer would have to keep track of matching
> > brackets.. hmmm..
> 
> Yes, not having the parser->lexer feedback would be great!  And this
> proposal seems like it should work quite well.  Somebody with a lot more
> spare time than me should code it up and see how much real code it
> breaks.

there is the helium layout rule:

http://www.cs.uu.nl/helium/docs/LayoutRule.html

which is similar to what I am thinking of but only has a special case
for 'in'.



my general thought is to take the layout rule algorithm from the haskell
report, and add some more possibiliies to the 'layout stack'.

so, right now it is 

layout :: [Token] -> [Int] -> [Token]

where the first argument is the token stream, the next argument is a
stack of layout contexts, and the result is the new token stream.

now we change it to something like (in semi-psuedo haskell)

data LContext = LExpects Token | LLevel Int

expectableTokens = ['of','in',')','}',']']

and change the signature to 

layout :: [Token] -> [LContext] -> [Token]
layout = ...

now, LLevel nodes will be pushed just like the old algorihm, but
whenever a 'case' for instance is encountered, a "LExpects 'of'" node
will be pushed.

now, whenever we get something in expectableTokens, an 'of' say, either
the top of the stack is a LExpects 'of', in which case we pop it add the
'of' to the output stream and continue, or it is a 'LLevel' in which
case we insert a '}' then pop the LLevel and continue (with the 'of'
still in the input stream)

I think something like this could work.

the only odd bits I can think of are handling 'let's without 'in's as
occur in 'do' blocks, and the comma, but I think we can integrate them
too.

does something like this seem like it will work?

John 

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Carl Witty
On Wed, 2006-12-06 at 16:56 -0800, John Meacham wrote:
> Having played with haskell parsers for various reasons, the layout rule
> is quite tricky due to the rules involving 'parse-error'. if we could
> come up with a formulation that didn't have those. it would make things
> a whole lot nicer. something like an unexpected 'in', 'of', ')' '}'
> ']' might  do it. the lexer would have to keep track of matching
> brackets.. hmmm..

Yes, not having the parser->lexer feedback would be great!  And this
proposal seems like it should work quite well.  Somebody with a lot more
spare time than me should code it up and see how much real code it
breaks.

Carl Witty


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread John Meacham
On Thu, Dec 07, 2006 at 11:34:42AM +1100, Donald Bruce Stewart wrote:
> I'd like some more help from the editors in getting 2d layout right
> without trying. Here's a mockup of vim with vertical grey bars
> delimiting layout:
> 
> http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png
> 
> Does anyone know how to get this effect in vim (or emacs)?
> 
> Bonus points if the grey bars are draggable, changing the indenting.
> More bonus points for box-based navigation.

Having played with haskell parsers for various reasons, the layout rule
is quite tricky due to the rules involving 'parse-error'. if we could
come up with a formulation that didn't have those. it would make things
a whole lot nicer. something like an unexpected 'in', 'of', ')' '}'
']' might  do it. the lexer would have to keep track of matching
brackets.. hmmm..

John 

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Donald Bruce Stewart
dons:
> I'd like some more help from the editors in getting 2d layout right
> without trying. Here's a mockup of vim with vertical grey bars
> delimiting layout:
> 
> http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png
> 
> Does anyone know how to get this effect in vim (or emacs)?
> 
> Bonus points if the grey bars are draggable, changing the indenting.
> More bonus points for box-based navigation.

mbishop on #haskell pointed out that Kate can do this:

http://img172.imageshack.us/my.php?image=indentbu9.png

-- Don

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Donald Bruce Stewart
I'd like some more help from the editors in getting 2d layout right
without trying. Here's a mockup of vim with vertical grey bars
delimiting layout:

http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png

Does anyone know how to get this effect in vim (or emacs)?

Bonus points if the grey bars are draggable, changing the indenting.
More bonus points for box-based navigation.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe