[Xmonad] darcs patch: XPrompt: a module for easily writing gr... (and 3 more)

Andrea Rossato mailing_list at istitutocolli.org
Thu Aug 2 12:31:37 EDT 2007


On Thu, Aug 02, 2007 at 06:03:51PM +0200, Andrea Rossato wrote:
> Hi,

Hi,

as I said is not finished yet: the completion is not working properly.
Completions show up, but by pressing Tab the first one will be
selected and... well give it a try.

A description: basically it is a library for writing prompts. You need
to use mkXPrompt with the configuration (a default one is provided), a
prompt type, for which you have to declare a type and make it an
instance of the XPrompt class, by defining a showXPrompt method (will
be used to print the prompt).

The completion function is just a String -> IO [String] function. You
can used the ones provided by the readline bindings (such as in
ShellPrompt) or you can write your own. You can also use
mkComplFunFromList: just feed it with a list of possible completion.
Have alook at XMonadPrompt or SshPrompt to see how.

Completions: the prompt will try to complete each word with the same
completion function. This could be changed: giving a list of function,
a map so that the function can be chosen with regard to the previous
word... I don't know. If that is really going to be needed I can study
the problem.

History: no history so far, but there will be history support real
soon: we need to write the history to a file, though.

TODO: finish the completion stuff add history support, clean the code
(see below).

Aesthetics: the code is quite ugly I know. Actually I thought it was
going to be easier to write a prompt. It is not, after all. 

As you see I'm simple minded: just a huge StateT. At first I was
puzzled (actually I still am): I did not know whether I should write a
stand alone application or not. The ugly style is also due to the fact
that till now I did not take a decision. probably the code could be
broken down to smaller pieces, providing useful modules for other kind
of stuff. But I don't know, if this is useful after all.

Just a final word, dedicated to Tuomo, who is not very popular among
the free and open source software communities, lately. It was thank to
Tuomo that I discovered Haskell. At first I was exposed to darcs,
which Tuomo used for developing Ion, but I didn't care that much,
since usable darcs binaries can be easily found. Later I discovered
Riot and I felt intrigued by that language: I could almost understand
where the code was headed, but I just couldn't read it. It was a real
challenge and I took it seriously: first the SICP classes with a ghci
prompt under my fingers and then at least a couple of tutorials... I
needed to write to understand...;-)

And so, after a month and a half of deep study I started hacking the
ContactManager that comes as an example of hscurses usage. It's there,
I think, that I pick up this ugly style ...;-)

And now, a year after, I'm here writing for myself a Ion substitution.
Thanks to Tuomo, once again.

Have fun.
Andrea





More information about the Xmonad mailing list