Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mundane Utility: A Functional Shell

Mundane Utility: A Functional Shell

Functional programming is a useful technique. We spend a lot of time discussing it in the context of hard, challenging or interesting problems, but no where nearly enough in the context of mundane problems.

The UNIX shell, or command line interpreter. A simple, but useful program too often mistaken as complex, or mysterious. Almost every programmer is exposed to shells from a users perspective, but far fewer have ever implemented one, or even know where to start.

This talk aims to be a fun look at using functional programming in and around a traditional, some would say mundane, system utility. We will work through the concepts involved with implementing your own shell, and live code our way to a basic functional shell implemented in Haskell.

From this talk, attendees will walk a way with a better understanding of a program they use every day, as well as ideas and inspiration around using functional programming to solve mundane programming problems.

NOTE: this is the lead in to a workshop https://github.com/markhibberd/xsh

Mark Hibberd

May 08, 2017
Tweet

More Decks by Mark Hibberd

Other Decks in Programming

Transcript

  1. How did we get here… firmware boot loader kernel init

    getty note this is just one example sequence at this point onwards
  2. command parsing… <program> ::= lists EOF | EOF <lists> ::=

    list | list <separator> list <list> ::= list | list <and> pipeline | list <or> pipeline <pipeline> ::= pipeline | pipeline <pipe> command <command> ::= word | command word <separator> ::= ; <and> ::= && <or> ::= || <pipe> ::= | <word> ::= …
  3. fork() fork() ls | sort | uniq uniq sort ls

    xsh xsh xsh xsh process management…
  4. fork() fork() exec() ls | sort | uniq uniq sort

    ls xsh xsh xsh xsh process management…
  5. fork() fork() fork() exec() ls | sort | uniq uniq

    sort ls xsh xsh xsh xsh process management…
  6. fork() fork() fork() exec() exec() ls | sort | uniq

    uniq sort ls xsh xsh xsh xsh process management…
  7. fork() fork() fork() exec() exec() exec() ls | sort |

    uniq uniq sort ls xsh xsh xsh xsh process management…
  8. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() process management…
  9. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() fork() process management…
  10. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() fork() fork() process management…
  11. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() fork() fork() exec() process management…
  12. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() fork() fork() exec() exec() process management…
  13. ls | sort | uniq xsh xsh xsh xsh uniq

    sort ls fork() fork() fork() exec() exec() exec() process management…
  14. ls | sort | uniq fork() xsh xsh xsh xsh

    ls sort uniq process management…
  15. ls | sort | uniq fork() exec() xsh xsh xsh

    xsh ls sort uniq process management…
  16. ls | sort | uniq fork() fork() exec() xsh xsh

    xsh xsh ls sort uniq process management…
  17. ls | sort | uniq fork() fork() exec() exec() xsh

    xsh xsh xsh ls sort uniq process management…
  18. ls | sort | uniq fork() fork() fork() exec() exec()

    xsh xsh xsh xsh ls sort uniq process management…
  19. ls | sort | uniq fork() fork() fork() exec() exec()

    exec() xsh xsh xsh xsh ls sort uniq process management…