Onorio CatenacciShell Scripting With F#
CodeStock is proudly partnered with:                RecruitWise and Staff with Excellence - www.recruitwise.jobs      Send...
what we do consulting       training     design      debuggingwho we are Founded by top experts on Microsoft – Jeffrey Ric...
• What We’ll Discuss                            – Important BackgroundShell Scripting With F#                            –...
• Important Background                            – Shell Scripting                              • Want It LightweightShel...
• Important Background                            – Functional Programming                                Immutable data b...
• Important Background                            – F#                              • ML language familyShell Scripting Wi...
• Why Write A Shell Script?                            – Wrap functionality which you can’t                              c...
• Why Use F# For Shell Scripting?                            – One language which scalesShell Scripting With F#           ...
• Code                            – Command Line                              • "C:Program Files (x86)MicrosoftShell Scrip...
• Additional Resources                            – Chris Smith’s “Scripting In F#”Shell Scripting With F#                ...
Upcoming SlideShare
Loading in …5
×

Shell scripting with f

885 views

Published on

The slide deck from my talk at CodeStock 2012

Published in: Technology
  • Be the first to comment

Shell scripting with f

  1. 1. Onorio CatenacciShell Scripting With F#
  2. 2. CodeStock is proudly partnered with: RecruitWise and Staff with Excellence - www.recruitwise.jobs Send instant feedback on this session via Twitter: Send a direct message with the room number to @CodeStock d codestock 401 This session is great! For more information on sending feedback using Twitter while at CodeStock, please see the “CodeStock README” in your CodeStock guide.
  3. 3. what we do consulting training design debuggingwho we are Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – our mission is to help our customers achieve their goals through advanced software-based consulting and training solutions.how we do it Training • On-site instructor-led training Consulting & Debugging • Virtual instructor-led training • Architecture, analysis, and design services • Devscovery conferences • Full lifecycle custom software development • Content creation Design • Project management • User Experience Design • Debugging & performance tuning • Visual & Content Design • Video & Animation Production wintellect.com
  4. 4. • What We’ll Discuss – Important BackgroundShell Scripting With F# – Use cases – Code – Additional resources
  5. 5. • Important Background – Shell Scripting • Want It LightweightShell Scripting With F# – Rapid testing/prototyping – REPL • Often driving apps via command-line • Want One Language For All • Shell Scripting Languages – Cmd – VBScript – Powershell – Bash
  6. 6. • Important Background – Functional Programming Immutable data by default (ex. 1, 2)Shell Scripting With F# • • Lambda functions (ex. 3) • Functions are “first class” (ex. 4,5,6) • Currying/partial application vs. tupled parameters (ex. 7,8, 9) • Unit type (ex. 10) • All functions return a value
  7. 7. • Important Background – F# • ML language familyShell Scripting With F# – Standard ML – OCaml • Indentation sensitive by default • Types of values are inferred from usage • Some/None • |> (Pipe Forward) • All funcs must be declared before use
  8. 8. • Why Write A Shell Script? – Wrap functionality which you can’t changeShell Scripting With F# – Automate common operations – Large batch jobs
  9. 9. • Why Use F# For Shell Scripting? – One language which scalesShell Scripting With F# – Low ceremony • Type inference – Default immutability – Good way to practice FP – Free to choose your own for shell scripting
  10. 10. • Code – Command Line • "C:Program Files (x86)MicrosoftShell Scripting With F# F#v4.0Fsi.exe" --exec <name of .fsx> <args> • Args are passed as array of strings • args.[0] is name of script; actual args start at args.[1] • Last line of fsx invokes main func and passes commandline args: – main fsi.CommandLineArgs;;
  11. 11. • Additional Resources – Chris Smith’s “Scripting In F#”Shell Scripting With F# • http://blogs.msdn.com/b/chrsmith/archive/2008/09/ 12/scripting-in-f.aspx – Programming F# 3.0 • Chapter on F# Shell Scripting and Common Idioms – Fake (F# Make Files) (Steffen Forkmann) • https://github.com/forki/FAKE – Finnikin (F# Shell Scripting Utility Library) • https://github.com/OnorioCatenacci/finnikin

×