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. what we do
consulting training design debugging
who 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. • What We’ll Discuss
– Important Background
Shell Scripting With F#
– Use cases
– Code
– Additional resources
5. • Important Background
– Shell Scripting
• Want It Lightweight
Shell 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. • 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. • Important Background
– F#
• ML language family
Shell 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. • Why Write A Shell Script?
– Wrap functionality which you can’t
change
Shell Scripting With F#
– Automate common operations
– Large batch jobs
9. • Why Use F# For Shell Scripting?
– One language which scales
Shell Scripting With F#
– Low ceremony
• Type inference
– Default immutability
– Good way to practice FP
– Free to choose your own for shell
scripting
10. • Code
– Command Line
• "C:Program Files (x86)Microsoft
Shell 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. • 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