[Nix-dev] Use Haskell for Shell Scripting

Michael Raskin 7c6f434c at mail.ru
Tue Feb 10 17:37: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.

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).

>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?

>>>> 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.

Why is it a problem? For hierarchically structured workspaces you just
tell XMonad core to select the low-level workspace.





More information about the nix-dev mailing list