FSharpx.Extras


Option

Namespace: FSharpx

Nested types and modules

TypeDescription
MaybeBuilder

The maybe monad. This monad is my own and uses an 'T option. Others generally make their own Maybe<'T> type from Option<'T>. The builder approach is from Matthew Podwysocki's excellent Creating Extended Builders series http://codebetter.com/blogs/matthew.podwysocki/archive/2010/01/18/much-ado-about-monads-creating-extended-builders.aspx.

Functions and values

Function or valueDescription
( *> ) x y
Signature: x:'?8800 option -> y:'?8801 option -> '?8801 option
Type parameters: '?8800, '?8801

Sequence actions, discarding the value of the first argument.

CompiledName: op_MultiplyGreater

( <!> ) f m
Signature: f:('?8793 -> '?8794) -> m:'?8793 option -> '?8794 option
Type parameters: '?8793, '?8794

Infix map

CompiledName: op_LessBangGreater

( <* ) x y
Signature: x:'?8803 option -> y:'?8804 option -> '?8803 option
Type parameters: '?8803, '?8804

Sequence actions, discarding the value of the second argument.

CompiledName: op_LessMultiply

( <*> ) f m
Signature: f:('?8787 -> '?8788) option -> m:'?8787 option -> '?8788 option
Type parameters: '?8787, '?8788

Sequential application

CompiledName: op_LessMultiplyGreater

( <=< ) x
Signature: x:('?8813 -> '?8814 option) -> ('?8815 -> '?8813 option) -> '?8815 -> '?8814 option
Type parameters: '?8813, '?8814, '?8815

Right-to-left Kleisli composition

CompiledName: op_LessEqualsLess

( =<< ) f m
Signature: f:('?8784 -> '?8785 option) -> m:'?8784 option -> '?8785 option
Type parameters: '?8784, '?8785

Flipped >>=

CompiledName: op_EqualsLessLess

( >=> ) f g x
Signature: f:('?8809 -> '?8810 option) -> g:('?8810 -> '?8811 option) -> x:'?8809 -> '?8811 option
Type parameters: '?8809, '?8810, '?8811

Left-to-right Kleisli composition

CompiledName: op_GreaterEqualsGreater

( >>. ) m f
Signature: m:'?8806 option -> f:'?8807 option -> '?8807 option
Type parameters: '?8806, '?8807

Sequentially compose two maybe actions, discarding any value produced by the first

CompiledName: op_GreaterGreaterDot

( >>= ) m f
Signature: m:'?8781 option -> f:('?8781 -> '?8782 option) -> '?8782 option
Type parameters: '?8781, '?8782

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

CompiledName: op_GreaterGreaterEquals

ap m f
Signature: m:'?8790 option -> f:('?8790 -> '?8791) option -> '?8791 option
Type parameters: '?8790, '?8791

Sequential application

cast o
Signature: o:obj -> '?8851 option
Type parameters: '?8851

Attempts to cast an object. Returns None if unsuccessful.

CompiledName: Cast

concat x
Signature: x:'?8870 option option -> '?8870 option
Type parameters: '?8870

Concatenates an option of option.

filter pred _arg1
Signature: pred:('b -> bool) -> _arg1:'b option -> 'b option
Type parameters: 'b

Applies a predicate to the option. If the predicate returns true, returns Some x, otherwise None.

foldM f s
Signature: f:('?8853 -> '?8854 -> '?8853 option) -> s:'?8853 -> seq<'?8854> -> '?8853 option
Type parameters: '?8853, '?8854
fromTryPattern tryFun input
Signature: tryFun:('input -> bool * 'output) -> input:'input -> 'output option
Type parameters: 'input, 'output

transforms a function in the Try...(input, out output) style into a function of type: input -> output Option Example: fromTryPattern(System.Double.TryParse) See Examples.Option

getOrDefault _arg1
Signature: _arg1:'?8845 option -> '?8845
Type parameters: '?8845

Gets the value associated with the option or the default value for the type.

getOrElse v _arg1
Signature: v:'?8830 -> _arg1:'?8830 option -> '?8830
Type parameters: '?8830

Gets the value associated with the option or the supplied default value.

getOrElseF v _arg1
Signature: v:(unit -> '?8834) -> _arg1:'?8834 option -> '?8834
Type parameters: '?8834

Gets the value associated with the option or the supplied default value from a function.

getOrElseLazy v _arg1
Signature: v:Lazy<'?8832> -> _arg1:'?8832 option -> '?8832
Type parameters: '?8832

Gets the value associated with the option or the supplied default value.

getOrElseWith v f _arg1
Signature: v:'?8861 -> f:('?8862 -> '?8861) -> _arg1:'?8862 option -> '?8861
Type parameters: '?8861, '?8862
getOrFail m _arg1
Signature: m:string -> _arg1:'?8836 option -> '?8836
Type parameters: '?8836

Gets the value associated with the option or fails with the supplied message.

getOrFailF fmt _arg1
Signature: fmt:StringFormat<'?8838,'?8839> -> _arg1:'?8838 option -> '?8838
Type parameters: '?8838, '?8839

Gets the value associated with the option or print to a string buffer and raise an exception with the given result. Helper printers must return strings.

getOrRaise e _arg1
Signature: e:Exception -> _arg1:'?8841 option -> '?8841
Type parameters: '?8841

Gets the value associated with the option or raises the supplied exception.

getOrReraise e _arg1
Signature: e:exn -> _arg1:'?8843 option -> '?8843
Type parameters: '?8843

Gets the value associated with the option or reraises the supplied exception.

lift2 f a b
Signature: f:('d -> 'e -> 'f) -> a:'d option -> b:'e option -> 'f option
Type parameters: 'd, 'e, 'f

Promote a function to a monad/applicative, scanning the monadic/applicative arguments from left to right.

mapM f x
Signature: f:('?8858 -> '?8859 option) -> x:'?8858 list -> '?8859 list option
Type parameters: '?8858, '?8859
maybe
Signature: MaybeBuilder
monoid m
Signature: m:ISemigroup<'?8777> -> Monoid<'?8777 option>
Type parameters: '?8777

Option wrapper monoid

ofBool b
Signature: b:bool -> unit option

True -> Some(), False -> None

ofBoolAndValue (arg1, arg2)
Signature: (bool * '?8825) -> '?8825 option
Type parameters: '?8825

If true,value then returns Some value. Otherwise returns None. Useful to process TryXX style functions.

ofChoice _arg1
Signature: _arg1:Choice<'c,'d> -> 'c option
Type parameters: 'c, 'd

Maps Choice 1Of2 to Some value, otherwise None.

ofNullable n
Signature: n:Nullable<'?8817> -> '?8817 option
Type parameters: '?8817

Maps a Nullable to Option

option defaultValue map _arg1
Signature: defaultValue:'U -> map:('T -> 'U) -> _arg1:'T option -> 'U
Type parameters: 'U, 'T

Haskell-style maybe operator

orElse v _arg1
Signature: v:'?8847 option -> _arg1:'?8847 option -> '?8847 option
Type parameters: '?8847

Gets the option if Some x, otherwise the supplied default value.

returnM x
Signature: x:'?8779 -> '?8779 option
Type parameters: '?8779

Inject a value into the option type

sequence s
Signature: s:'b option list -> 'b list option
Type parameters: 'b
toNullable _arg1
Signature: _arg1:'?8819 option -> Nullable<'?8819>
Type parameters: '?8819

Maps an Option to Nullable

tryParseWith func
Signature: func:('?8822 -> bool * '?8823) -> '?8822 -> '?8823 option
Type parameters: '?8822, '?8823

Converts a function returning bool,value to a function returning value option. Useful to process TryXX style functions.

Fork me on GitHub