[Nix-dev] Use Haskell for Shell Scripting

Ertugrul Söylemez ertesx at gmx.de
Tue Feb 10 18:15:38 CET 2015


>> 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.
>
> Actually, I use a ton of tuples-as-records in my crunching code in
> Common Lisp or Julia.
>
> Some of the shell tricks based on expansions are portable to Lisp, not
> worth it in Julia and definitely too costly in Haskell (learning
> Template Haskell is definitely outside my plans).

I don't really know TH either.  Occasionally I use TH actions defined in
a library (for example to derive safecopy instances or, less commonly,
to auto-generate lenses).  But TH somehow feels wrong and ugly.


>> However, you may want to write type signatures anyway.  It doesn't
>> increase your development time considerably.
>
> I also need to write matching to extract data from deep structures,
> no?

I'm not sure what you mean by that.  Perhaps you can drop me an off-list
mail, so we can talk about your specific application.


>>>> 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.
>
> Why is it a problem? For hierarchically structured workspaces you just
> tell XMonad core to select the low-level workspace.

The trouble is that xmonad's idea of "set of workspaces" is encoded as a
list zipper.  It does not allow me to encode the tree.  It only ever
holds *lists* of workspaces and does not abstract over this data
structure.
-------------- 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/31f35073/attachment-0001.bin 


More information about the nix-dev mailing list