Real World-ish examples
1: 2: 3: 4: |
|
Doing the things found in this MSDN Blog Post did with the Safe Nav operator
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: |
|
Guard is just an easy wait for nulloptable binding while dealing with mutations and external state.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
Modified this recursive prime fucntion from F# docs example.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|
Solution using option {}
for this RNA Transcription problem from exercism.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: |
|
Solution using chooseSeq {}
for this Rain Drops (Fizz buzz) problem from exercism.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: |
|
Example using option {}
for All Your Base problem from exercism.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: |
|
module RealWorldTests
namespace System
namespace System.Text
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Interop
namespace FSharp.Interop.NullOptAble
val ( Basic nullable math ) : unit -> 'a
val x : obj
val y : obj
Multiple items
val option : OptionBuilder
--------------------
type 'T option = Option<'T>
val option : OptionBuilder
--------------------
type 'T option = Option<'T>
union case Option.Some: Value: 'T -> Option<'T>
Multiple items
type AllowNullLiteralAttribute =
inherit Attribute
new : unit -> AllowNullLiteralAttribute
new : value:bool -> AllowNullLiteralAttribute
member Value : bool
--------------------
new : unit -> AllowNullLiteralAttribute
new : value:bool -> AllowNullLiteralAttribute
type AllowNullLiteralAttribute =
inherit Attribute
new : unit -> AllowNullLiteralAttribute
new : value:bool -> AllowNullLiteralAttribute
member Value : bool
--------------------
new : unit -> AllowNullLiteralAttribute
new : value:bool -> AllowNullLiteralAttribute
Multiple items
type Node =
new : unit -> Node
new : child:Node -> Node
member child : Node
member child : Node with set
--------------------
new : unit -> Node
new : child:Node -> Node
type Node =
new : unit -> Node
new : child:Node -> Node
member child : Node
member child : Node with set
--------------------
new : unit -> Node
new : child:Node -> Node
val child : Node
val set : elements:seq<'T> -> Set<'T> (requires comparison)
val ( Safe Navigation Operator Example ) : unit -> 'a
val parent : Node
property Node.child: Node
union case Option.None: Option<'T>
val ( Safe Navigation Operator Seq Example ) : unit -> 'a
val parents : Node list
val chooseSeq : ChooseSeqBuilder
module Seq
from Microsoft.FSharp.Collections
from Microsoft.FSharp.Collections
val length : source:seq<'T> -> int
type Setup =
{ShouldWriteFile: bool;}
{ShouldWriteFile: bool;}
Setup.ShouldWriteFile: bool
type bool = System.Boolean
val ( Guard Example, for dealing with non functional statey things ) : unit -> 'a
val overrideSetup : Setup option
val randoFilename : string
val existsActual : bool
namespace System.IO
type File =
static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
static member AppendAllLinesAsync : path:string * contents:IEnumerable<string> * ?cancellationToken:CancellationToken -> Task + 1 overload
static member AppendAllText : path:string * contents:string -> unit + 1 overload
static member AppendAllTextAsync : path:string * contents:string * ?cancellationToken:CancellationToken -> Task + 1 overload
static member AppendText : path:string -> StreamWriter
static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
static member Create : path:string -> FileStream + 3 overloads
static member CreateText : path:string -> StreamWriter
static member Decrypt : path:string -> unit
static member Delete : path:string -> unit
...
static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
static member AppendAllLinesAsync : path:string * contents:IEnumerable<string> * ?cancellationToken:CancellationToken -> Task + 1 overload
static member AppendAllText : path:string * contents:string -> unit + 1 overload
static member AppendAllTextAsync : path:string * contents:string * ?cancellationToken:CancellationToken -> Task + 1 overload
static member AppendText : path:string -> StreamWriter
static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
static member Create : path:string -> FileStream + 3 overloads
static member CreateText : path:string -> StreamWriter
static member Decrypt : path:string -> unit
static member Delete : path:string -> unit
...
System.IO.File.Exists(path: string) : bool
val guard : GuardBuilder
System.IO.File.Open(path: string, mode: System.IO.FileMode) : System.IO.FileStream
System.IO.File.Open(path: string, mode: System.IO.FileMode, access: System.IO.FileAccess) : System.IO.FileStream
System.IO.File.Open(path: string, mode: System.IO.FileMode, access: System.IO.FileAccess, share: System.IO.FileShare) : System.IO.FileStream
System.IO.File.Open(path: string, mode: System.IO.FileMode, access: System.IO.FileAccess) : System.IO.FileStream
System.IO.File.Open(path: string, mode: System.IO.FileMode, access: System.IO.FileAccess, share: System.IO.FileShare) : System.IO.FileStream
val ( IsPrime Example ) : unit -> 'a
val isprime : (int -> int option)
val n : int
val check : (int -> bool)
val i : int
Multiple items
module Option
from FSharp.Interop.NullOptAble
--------------------
module Option
from Microsoft.FSharp.Core
module Option
from FSharp.Interop.NullOptAble
--------------------
module Option
from Microsoft.FSharp.Core
val ofTryTuple : value:(bool * 'a) -> 'a option
val prime : seq<obj>
val toList : source:seq<'T> -> 'T list
val ( RNA transcriptions ) : unit -> 'a
val toRna : (string -> string option)
val dna : string
Multiple items
val string : value:'T -> string
--------------------
type string = System.String
val string : value:'T -> string
--------------------
type string = System.String
val combine : (StringBuilder option -> char -> 'b option)
val sb : StringBuilder option
Multiple items
type StringBuilder =
new : unit -> StringBuilder + 5 overloads
member Append : value:string -> StringBuilder + 22 overloads
member AppendFormat : format:string * arg0:obj -> StringBuilder + 7 overloads
member AppendJoin : separator:string * [<ParamArray>] values:obj[] -> StringBuilder + 5 overloads
member AppendLine : unit -> StringBuilder + 1 overload
member Capacity : int with get, set
member Chars : int -> char with get, set
member Clear : unit -> StringBuilder
member CopyTo : sourceIndex:int * destination:Span<char> * count:int -> unit + 1 overload
member EnsureCapacity : capacity:int -> int
...
--------------------
StringBuilder() : StringBuilder
StringBuilder(capacity: int) : StringBuilder
StringBuilder(value: string) : StringBuilder
StringBuilder(value: string, capacity: int) : StringBuilder
StringBuilder(capacity: int, maxCapacity: int) : StringBuilder
StringBuilder(value: string, startIndex: int, length: int, capacity: int) : StringBuilder
type StringBuilder =
new : unit -> StringBuilder + 5 overloads
member Append : value:string -> StringBuilder + 22 overloads
member AppendFormat : format:string * arg0:obj -> StringBuilder + 7 overloads
member AppendJoin : separator:string * [<ParamArray>] values:obj[] -> StringBuilder + 5 overloads
member AppendLine : unit -> StringBuilder + 1 overload
member Capacity : int with get, set
member Chars : int -> char with get, set
member Clear : unit -> StringBuilder
member CopyTo : sourceIndex:int * destination:Span<char> * count:int -> unit + 1 overload
member EnsureCapacity : capacity:int -> int
...
--------------------
StringBuilder() : StringBuilder
StringBuilder(capacity: int) : StringBuilder
StringBuilder(value: string) : StringBuilder
StringBuilder(value: string, capacity: int) : StringBuilder
StringBuilder(capacity: int, maxCapacity: int) : StringBuilder
StringBuilder(value: string, startIndex: int, length: int, capacity: int) : StringBuilder
val append : (char -> 'c)
val c : char
Multiple items
val char : value:'T -> char (requires member op_Explicit)
--------------------
type char = System.Char
val char : value:'T -> char (requires member op_Explicit)
--------------------
type char = System.Char
val ___ : char
val fold : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> 'State
val ( rain drops ) : unit -> 'a
val convert : (int -> string)
val number : int
Multiple items
val int : value:'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
val int : value:'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
val drop : (int -> 'b -> 'b option)
val x : int
val s : 'b
module String
from Microsoft.FSharp.Core
from Microsoft.FSharp.Core
val concat : sep:string -> strings:seq<string> -> string
val s : string
val ( All your Base ) : unit -> 'a
val rebase : ('b -> 'c -> 'd -> 'e)
val digits : 'b
val inputBase : 'c
val outputBase : 'd
val fromBase : ('f -> 'g list -> int option)
val b : 'f
val digits' : 'g list
val foldToBase10 : (int option -> 'h -> 'i)
val acc : int option
val d : 'h
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetSlice : startIndex:int option * endIndex:int option -> 'T list
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
...
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetSlice : startIndex:int option * endIndex:int option -> 'T list
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
...
val fold : folder:('State -> 'T -> 'State) -> state:'State -> list:'T list -> 'State
val toBase : ('f -> 'g -> 'h)
val n : 'g
val initInfinite : initializer:(int -> 'T) -> seq<'T>
val ignore : value:'T -> unit
val scan : folder:('State -> 'T -> 'State) -> state:'State -> source:seq<'T> -> seq<'State>
val pairwise : source:seq<'T> -> seq<'T * 'T>
val takeWhile : predicate:('T -> bool) -> source:seq<'T> -> seq<'T>
val fst : tuple:('T1 * 'T2) -> 'T1
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>
val snd : tuple:('T1 * 'T2) -> 'T2
val skipWhile : predicate:('T -> bool) -> list:'T list -> 'T list