[Haskell-cafe] Need help to get started

tech at jimtyrerrobotics.ca tech at jimtyrerrobotics.ca
Sat Oct 17 20:22:03 UTC 2020

I'm an industrial robot tech and the code I write seems to be composed 
of 99% side-effects ;-)
That's the big dumb ones bolted to the floor that make cars and stuff.
Decades of imperative sequence coding seem to have fossilized something 
in my brain.

Trying to teach myself Haskell and going nowhere very slowly.
Spent the last 8 weeks slowly plodding through "Real World Haskell" and 
"Learn you a Haskell" with the intention of re-writing a bash script in 
I've normally learned programming by writing something I need instead of 
tutorials with which I seem to have an attention deficit problem.

I use Linux for work and have written a bash script that uses bc and 
heredocs to write an .adoc file and then calls asciidoctor-pdf to 
generate an invoice.
It's about 90 lines so I am not a scripting pro either.
So typing './invoice Wk38' rolls a file called Wk38-of-2020-Invoice.pdf 
to send to clients.

It was while writing this script that I stumbled upon pandoc and then 
And that's where the trouble started.
Tha abstraction and macro-approach of Haskell could provide a whole bag 
of tools for maintaining code (text files) on lines of multiple robots.

About the existing script:
I write plain text files on my phone that look like this:

  14 Sep 0745 1600 Foo y
  15 Sep 0815 1500 Foo y
  16 Sep 0745 1400 Foo y
  17 Sep 0745 1430 Foo y
  18 Sep 0745 1400 Foo y

and this one is called Wk38 and the fields are: |Date|Time In|Time 
Then I email it to myself and run the script.

So I would be very grateful if someone could write some code for me and 
put my bootstraps in my fumbling hands:

  Get the name of the Wkxx file from the command line when running a 
Haskell standalone executable.
  fileName <- getArgs
  Load the lines of the file into a list of list of String[[]]. (or a 
better way?)
  lines <- fmap Text.lines (Text.readFile fileName)
  Recurse through each line of the list(s) and:
  *:  Construct a date::String from the first two fields. (just a string, 
does not need a real "Date")
  *:  Calc dailyElapsedTime::Double from difference between fields 4 and 
  *:  Subtract 0.5hr lunch from dailyElapsedTime if field 6 == "y"
  *:  Add dailyElapsedTime to accumlatedWeekTime::Double.
  *:  Charge = If accumlatedWeekTime < 40hrs then multiply by rate1
  *:           elseif accumlatedWeekTime > 40hrs then multiply by rate2
  *:  Append |Date|Time In|Time Out|Charge|Project| to adoc file.

If I could load it into ghci and step through it the lights may come on.
Thanks very much

More information about the Haskell-Cafe mailing list