[Nix-dev] Use Haskell for Shell Scripting

Ertugrul Söylemez ertesx at gmx.de
Tue Feb 10 17:27:19 CET 2015


>>> Data type declarations are not free in any case, I think.
>>
>> Compared to what?  Algebraic abstractions usually compile to exactly
>> the code you would have written if you had not used abstraction.
>
> Data type declarations have to be written. Store-everything-in-hash-
> tables is slower but quicker to write as long as I can keep the entire
> program structure in my head.
>
> Also I am trying to learn to write reasonable Haskell code for a small
> data-crunching script without just "writing Fortran into Haskell";
> well, many of its features are minor annoyances in that mode even if
> they are useful for giving structure to a large program.

It's seldom that you have to write your own data types, if you don't
want to.  Basic types, functions, products and coproducts can express
anything you want that isn't a tightly packed array of machine words.

But if you really want to dump everything into a table-like data
structure, you can use Data.Map or Data.IntMap for everything.  Together
with GHC's OverloadedLists extension this should make your code just as
short as the usual everything-is-a-hash-table in most scripting
languages.

However, you may want to write type signatures anyway.  It doesn't
increase your development time considerably.


>>> Well, you started talking like you were considering some limitation
>>> of XMonad hard to work around.
>>
>> I am.  I'm using a tree-shaped set of workspaces, but I need to
>> encode this tree within the names of the workspaces, which is
>> incredibly awkward.
>
> Well, I think you should be able just to write alternative UI for
> workspace selection simply ignoring the old one, no?

Unfortunately not.  Everything in xmonad goes through the core data
structure StackSet.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150210/98f6300f/attachment.bin 


More information about the nix-dev mailing list