📎 Webclip
Succinct FSharp
Page walks through F# through examples and explanations, starting with F# Interactive and basic evaluation in fsi. It then covers immutable bindings, let, mutable values, whitespace sensitivity, primitive types, strings, tuples, collections, slices, comments, conditionals, loops, functions, currying, pipelines, recursion, and pattern matching.
Reading notes#
fsiis presented as a practical way to learn F#, started withdotnet fsiand controlled with#help;;,#quit;;, and;;to end input.- Expression results are stored in
it, which has a type, anditis not mutable. letcreates bindings,let mutablecreates variables that can be updated with<-, and=is used for comparison.let..inis shown as equivalent tolet, and lambda functions are introduced through that equivalence.- Double-backtick identifiers allow names with spaces and symbols.
- F# is whitespace sensitive and uses indentation instead of braces.
- Primitive types listed include
bool,byte,int,float,double,float32,single,char,string, andunit. - Strings can be concatenated, written as verbatim strings with
@, written as multiline strings with triple quotes, or interpolated with$. - Tuples can hold values of different types, be deconstructed, and be accessed with
fstandsnd. - Lists are immutable, arrays are fixed-size and mutable, sequences are lazy, and slices work on lists, arrays, and 2-D arrays.
- Comments can be block, line, or XML doc comments.
if..then..else,for..in,for..to, andwhile..doare presented as expressions.- Functions are defined with
let, can have explicit types, can be anonymous, can capture outer bindings, and can be curried. - Pipe
|>and composition>>are shown for chaining functions. - Recursive functions use
rec, and mutual recursion usesand. - Pattern matching uses
match, with_as wildcard andwhenas a guard. functionis presented as shorthand forfun x -> match x with.- Cons patterns, active patterns, parameterized active patterns, and partial active patterns are included.
- Records, anonymous records, discriminated unions,
option, andResultare covered as data modeling tools. - Generic type inference and automatic generalization are shown with generic list functions.
- Exceptions are handled with
failwith,try/with, custom exceptions, andtry/finally. - Classes, inheritance, interfaces, object expressions, and compiler directives such as
#load,#r,#I, and#if INTERACTIVEclose the page.
