sscanf - parsing with format strings

A more complete version of sscanf, as proposed on stackoverflow by kvb: http://stackoverflow.com/questions/2415705/read-from-console-in-f

Copy Source
Copy Link
Tools:
 1: open System
 2: open System.Text
 3: open System.Text.RegularExpressions
 4: open Microsoft.FSharp.Reflection
 5: 
 6: 
 7: let check f x = if f x then x
 8:                 else failwithf "format failure \"%s\"" x
 9: 
10: 
11: let parseDecimal x = Decimal.Parse(x, System.Globalization.CultureInfo.InvariantCulture)
12: 
13: 
14: let parsers = dict [
15:                  'b', Boolean.Parse >> box
16:                  'd', int >> box
17:                  'i', int >> box
18:                  's', box
19:                  'u', uint32 >> int >> box
20:                  'x', check (String.forall Char.IsLower) >> ((+) "0x") >> int >> box
21:                  'X', check (String.forall Char.IsUpper) >> ((+) "0x") >> int >> box
22:                  'o', ((+) "0o") >> int >> box
23:                  'e', float >> box // no check for correct format for floats
24:                  'E', float >> box
25:                  'f', float >> box
26:                  'F', float >> box
27:                  'g', float >> box
28:                  'G', float >> box
29:                  'M', parseDecimal >> box
30:                  'c', char >> box
31:                 ]
32: 
33: 
34: // array of all possible formatters, i.e. [|"%b"; "%d"; ...|]
35: let separators =
36:    parsers.Keys
37:    |> Seq.map (fun c -> sprintf "%%%c" c)
38:    |> Seq.toArray
39: 
40: 
41: // Creates a list of formatter characters from a format string,
42: // for example "(%s,%d)" -> ['s', 'd']
43: let rec getFormatters xs =
44:    match xs with
45:    | '%'::'%'::xr -> getFormatters xr
46:    | '%'::x::xr -> if parsers.ContainsKey x then x::getFormatters xr
47:                    else failwithf "Unknown formatter %%%c" x
48:    | x::xr -> getFormatters xr
49:    | [] -> []
50: 
51: 
52: let sscanf (pf:PrintfFormat<_,_,_,_,'t>) s : 't =
53:   let formatStr = pf.Value.Replace("%%", "%")
54:   let constants = formatStr.Split(separators, StringSplitOptions.None)
55:   let regex = Regex("^" + String.Join("(.*?)", constants |> Array.map Regex.Escape) + "$")
56:   let formatters = pf.Value.ToCharArray() // need original string here (possibly with "%%"s)
57:                    |> Array.toList |> getFormatters 
58:   let groups = 
59:     regex.Match(s).Groups 
60:     |> Seq.cast<Group> 
61:     |> Seq.skip 1
62:   let matches =
63:     (groups, formatters)
64:     ||> Seq.map2 (fun g f -> g.Value |> parsers.[f])
65:     |> Seq.toArray
66: 
67:   if matches.Length = 1 then matches.[0] :?> 't
68:   else FSharpValue.MakeTuple(matches, typeof<'t>) :?> 't
69: 
70: // some basic testing
71: let (a,b) = sscanf "(%%%s,%M)" "(%hello, 4.53)"
72: let (x,y,z) = sscanf "%s-%s-%s" "test-this-string"
73: let (c,d,e,f,g,h,i) = sscanf "%b-%d-%i,%u,%x,%X,%o" "false-42--31,13,ff,FF,42"
74: let (j,k,l,m,n,o,p) = sscanf "%f %F %g %G %e %E %c" "1 2.1 3.4 .3 43.2e32 0 f"
namespace System
namespace System.Text
namespace System.Text.RegularExpressions
namespace Microsoft
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Reflection
val check : (string -> bool) -> string -> string

Full name: Snippet.check
val f : (string -> bool)
val x : string

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val failwithf : Printf.StringFormat<'T,'Result> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.failwithf
val parseDecimal : string -> decimal

Full name: Snippet.parseDecimal
type Decimal =
  struct
    new : int -> decimal
    new : uint32 -> decimal
    new : int64 -> decimal
    new : uint64 -> decimal
    new : float32 -> decimal
    new : float -> decimal
    new : int [] -> decimal
    new : int * int * int * bool * System.Byte -> decimal
    member CompareTo : obj -> int
    member CompareTo : decimal -> int
    member Equals : obj -> bool
    member Equals : decimal -> bool
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> System.TypeCode
    member ToString : unit -> string
    member ToString : string -> string
    member ToString : System.IFormatProvider -> string
    member ToString : string * System.IFormatProvider -> string
    static val Zero : decimal
    static val One : decimal
    static val MinusOne : decimal
    static val MaxValue : decimal
    static val MinValue : decimal
    static member Add : decimal * decimal -> decimal
    static member Ceiling : decimal -> decimal
    static member Compare : decimal * decimal -> int
    static member Divide : decimal * decimal -> decimal
    static member Equals : decimal * decimal -> bool
    static member Floor : decimal -> decimal
    static member FromOACurrency : int64 -> decimal
    static member GetBits : decimal -> int []
    static member Multiply : decimal * decimal -> decimal
    static member Negate : decimal -> decimal
    static member Parse : string -> decimal
    static member Parse : string * System.Globalization.NumberStyles -> decimal
    static member Parse : string * System.IFormatProvider -> decimal
    static member Parse : string * System.Globalization.NumberStyles * System.IFormatProvider -> decimal
    static member Remainder : decimal * decimal -> decimal
    static member Round : decimal -> decimal
    static member Round : decimal * int -> decimal
    static member Round : decimal * System.MidpointRounding -> decimal
    static member Round : decimal * int * System.MidpointRounding -> decimal
    static member Subtract : decimal * decimal -> decimal
    static member ToByte : decimal -> System.Byte
    static member ToDouble : decimal -> float
    static member ToInt16 : decimal -> int16
    static member ToInt32 : decimal -> int
    static member ToInt64 : decimal -> int64
    static member ToOACurrency : decimal -> int64
    static member ToSByte : decimal -> System.SByte
    static member ToSingle : decimal -> float32
    static member ToUInt16 : decimal -> uint16
    static member ToUInt32 : decimal -> uint32
    static member ToUInt64 : decimal -> uint64
    static member Truncate : decimal -> decimal
    static member TryParse : string * decimal -> bool
    static member TryParse : string * System.Globalization.NumberStyles * System.IFormatProvider * decimal -> bool
  end

Full name: System.Decimal

  type: Decimal
  implements: IFormattable
  implements: IComparable
  implements: IConvertible
  implements: Runtime.Serialization.IDeserializationCallback
  implements: IComparable<decimal>
  implements: IEquatable<decimal>
  inherits: ValueType
Multiple overloads
Decimal.Parse(s: string) : decimal
Decimal.Parse(s: string, provider: IFormatProvider) : decimal
Decimal.Parse(s: string, style: Globalization.NumberStyles) : decimal
Decimal.Parse(s: string, style: Globalization.NumberStyles, provider: IFormatProvider) : decimal
namespace System.Globalization
type CultureInfo =
  class
    new : string -> System.Globalization.CultureInfo
    new : string * bool -> System.Globalization.CultureInfo
    new : int -> System.Globalization.CultureInfo
    new : int * bool -> System.Globalization.CultureInfo
    member Calendar : System.Globalization.Calendar
    member ClearCachedData : unit -> unit
    member Clone : unit -> obj
    member CompareInfo : System.Globalization.CompareInfo
    member CultureTypes : System.Globalization.CultureTypes
    member DateTimeFormat : System.Globalization.DateTimeFormatInfo with get, set
    member DisplayName : string
    member EnglishName : string
    member Equals : obj -> bool
    member GetConsoleFallbackUICulture : unit -> System.Globalization.CultureInfo
    member GetFormat : System.Type -> obj
    member GetHashCode : unit -> int
    member IetfLanguageTag : string
    member IsNeutralCulture : bool
    member IsReadOnly : bool
    member KeyboardLayoutId : int
    member LCID : int
    member Name : string
    member NativeName : string
    member NumberFormat : System.Globalization.NumberFormatInfo with get, set
    member OptionalCalendars : System.Globalization.Calendar []
    member Parent : System.Globalization.CultureInfo
    member TextInfo : System.Globalization.TextInfo
    member ThreeLetterISOLanguageName : string
    member ThreeLetterWindowsLanguageName : string
    member ToString : unit -> string
    member TwoLetterISOLanguageName : string
    member UseUserOverride : bool
    static member CreateSpecificCulture : string -> System.Globalization.CultureInfo
    static member CurrentCulture : System.Globalization.CultureInfo
    static member CurrentUICulture : System.Globalization.CultureInfo
    static member GetCultureInfo : int -> System.Globalization.CultureInfo
    static member GetCultureInfo : string -> System.Globalization.CultureInfo
    static member GetCultureInfo : string * string -> System.Globalization.CultureInfo
    static member GetCultureInfoByIetfLanguageTag : string -> System.Globalization.CultureInfo
    static member GetCultures : System.Globalization.CultureTypes -> System.Globalization.CultureInfo []
    static member InstalledUICulture : System.Globalization.CultureInfo
    static member InvariantCulture : System.Globalization.CultureInfo
    static member ReadOnly : System.Globalization.CultureInfo -> System.Globalization.CultureInfo
  end

Full name: System.Globalization.CultureInfo

  type: Globalization.CultureInfo
  implements: ICloneable
  implements: IFormatProvider
property Globalization.CultureInfo.InvariantCulture: Globalization.CultureInfo
val parsers : Collections.Generic.IDictionary<char,(string -> obj)>

Full name: Snippet.parsers

  type: Collections.Generic.IDictionary<char,(string -> obj)>
  inherits: Collections.Generic.ICollection<Collections.Generic.KeyValuePair<char,(string -> obj)>>
  inherits: seq<Collections.Generic.KeyValuePair<char,(string -> obj)>>
  inherits: Collections.IEnumerable
val dict : seq<'Key * 'Value> -> Collections.Generic.IDictionary<'Key,'Value> (requires equality)

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.dict
type Boolean =
  struct
    member CompareTo : obj -> int
    member CompareTo : bool -> int
    member Equals : obj -> bool
    member Equals : bool -> bool
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> System.TypeCode
    member ToString : unit -> string
    member ToString : System.IFormatProvider -> string
    static val TrueString : string
    static val FalseString : string
    static member Parse : string -> bool
    static member TryParse : string * bool -> bool
  end

Full name: System.Boolean

  type: Boolean
  implements: IComparable
  implements: IConvertible
  implements: IComparable<bool>
  implements: IEquatable<bool>
  inherits: ValueType
Boolean.Parse(value: string) : bool
val box : 'T -> obj

Full name: Microsoft.FSharp.Core.Operators.box
Multiple items
val int : 'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------

type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>

  type: int<'Measure>
  implements: IComparable
  implements: IConvertible
  implements: IFormattable
  implements: IComparable<int<'Measure>>
  implements: IEquatable<int<'Measure>>
  inherits: ValueType


--------------------

type int = int32

Full name: Microsoft.FSharp.Core.int

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
Multiple items
val uint32 : 'T -> uint32 (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.uint32

--------------------

type uint32 = UInt32

Full name: Microsoft.FSharp.Core.uint32

  type: uint32
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint32>
  implements: IEquatable<uint32>
  inherits: ValueType
type String =
  class
    new : char -> string
    new : char * int * int -> string
    new : System.SByte -> string
    new : System.SByte * int * int -> string
    new : System.SByte * int * int * System.Text.Encoding -> string
    new : char [] * int * int -> string
    new : char [] -> string
    new : char * int -> string
    member Chars : int -> char
    member Clone : unit -> obj
    member CompareTo : obj -> int
    member CompareTo : string -> int
    member Contains : string -> bool
    member CopyTo : int * char [] * int * int -> unit
    member EndsWith : string -> bool
    member EndsWith : string * System.StringComparison -> bool
    member EndsWith : string * bool * System.Globalization.CultureInfo -> bool
    member Equals : obj -> bool
    member Equals : string -> bool
    member Equals : string * System.StringComparison -> bool
    member GetEnumerator : unit -> System.CharEnumerator
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> System.TypeCode
    member IndexOf : char -> int
    member IndexOf : string -> int
    member IndexOf : char * int -> int
    member IndexOf : string * int -> int
    member IndexOf : string * System.StringComparison -> int
    member IndexOf : char * int * int -> int
    member IndexOf : string * int * int -> int
    member IndexOf : string * int * System.StringComparison -> int
    member IndexOf : string * int * int * System.StringComparison -> int
    member IndexOfAny : char [] -> int
    member IndexOfAny : char [] * int -> int
    member IndexOfAny : char [] * int * int -> int
    member Insert : int * string -> string
    member IsNormalized : unit -> bool
    member IsNormalized : System.Text.NormalizationForm -> bool
    member LastIndexOf : char -> int
    member LastIndexOf : string -> int
    member LastIndexOf : char * int -> int
    member LastIndexOf : string * int -> int
    member LastIndexOf : string * System.StringComparison -> int
    member LastIndexOf : char * int * int -> int
    member LastIndexOf : string * int * int -> int
    member LastIndexOf : string * int * System.StringComparison -> int
    member LastIndexOf : string * int * int * System.StringComparison -> int
    member LastIndexOfAny : char [] -> int
    member LastIndexOfAny : char [] * int -> int
    member LastIndexOfAny : char [] * int * int -> int
    member Length : int
    member Normalize : unit -> string
    member Normalize : System.Text.NormalizationForm -> string
    member PadLeft : int -> string
    member PadLeft : int * char -> string
    member PadRight : int -> string
    member PadRight : int * char -> string
    member Remove : int -> string
    member Remove : int * int -> string
    member Replace : char * char -> string
    member Replace : string * string -> string
    member Split : char [] -> string []
    member Split : char [] * int -> string []
    member Split : char [] * System.StringSplitOptions -> string []
    member Split : string [] * System.StringSplitOptions -> string []
    member Split : char [] * int * System.StringSplitOptions -> string []
    member Split : string [] * int * System.StringSplitOptions -> string []
    member StartsWith : string -> bool
    member StartsWith : string * System.StringComparison -> bool
    member StartsWith : string * bool * System.Globalization.CultureInfo -> bool
    member Substring : int -> string
    member Substring : int * int -> string
    member ToCharArray : unit -> char []
    member ToCharArray : int * int -> char []
    member ToLower : unit -> string
    member ToLower : System.Globalization.CultureInfo -> string
    member ToLowerInvariant : unit -> string
    member ToString : unit -> string
    member ToString : System.IFormatProvider -> string
    member ToUpper : unit -> string
    member ToUpper : System.Globalization.CultureInfo -> string
    member ToUpperInvariant : unit -> string
    member Trim : unit -> string
    member Trim : char [] -> string
    member TrimEnd : char [] -> string
    member TrimStart : char [] -> string
    static val Empty : string
    static member Compare : string * string -> int
    static member Compare : string * string * bool -> int
    static member Compare : string * string * System.StringComparison -> int
    static member Compare : string * string * System.Globalization.CultureInfo * System.Globalization.CompareOptions -> int
    static member Compare : string * string * bool * System.Globalization.CultureInfo -> int
    static member Compare : string * int * string * int * int -> int
    static member Compare : string * int * string * int * int * bool -> int
    static member Compare : string * int * string * int * int * System.StringComparison -> int
    static member Compare : string * int * string * int * int * bool * System.Globalization.CultureInfo -> int
    static member Compare : string * int * string * int * int * System.Globalization.CultureInfo * System.Globalization.CompareOptions -> int
    static member CompareOrdinal : string * string -> int
    static member CompareOrdinal : string * int * string * int * int -> int
    static member Concat : obj -> string
    static member Concat : obj [] -> string
    static member Concat<'T> : System.Collections.Generic.IEnumerable<'T> -> string
    static member Concat : System.Collections.Generic.IEnumerable<string> -> string
    static member Concat : string [] -> string
    static member Concat : obj * obj -> string
    static member Concat : string * string -> string
    static member Concat : obj * obj * obj -> string
    static member Concat : string * string * string -> string
    static member Concat : obj * obj * obj * obj -> string
    static member Concat : string * string * string * string -> string
    static member Copy : string -> string
    static member Equals : string * string -> bool
    static member Equals : string * string * System.StringComparison -> bool
    static member Format : string * obj -> string
    static member Format : string * obj [] -> string
    static member Format : string * obj * obj -> string
    static member Format : System.IFormatProvider * string * obj [] -> string
    static member Format : string * obj * obj * obj -> string
    static member Intern : string -> string
    static member IsInterned : string -> string
    static member IsNullOrEmpty : string -> bool
    static member IsNullOrWhiteSpace : string -> bool
    static member Join : string * string [] -> string
    static member Join : string * obj [] -> string
    static member Join<'T> : string * System.Collections.Generic.IEnumerable<'T> -> string
    static member Join : string * System.Collections.Generic.IEnumerable<string> -> string
    static member Join : string * string [] * int * int -> string
  end

Full name: System.String

  type: String
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val forall : (char -> bool) -> string -> bool

Full name: Microsoft.FSharp.Core.String.forall
type Char =
  struct
    member CompareTo : obj -> int
    member CompareTo : char -> int
    member Equals : obj -> bool
    member Equals : char -> bool
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> System.TypeCode
    member ToString : unit -> string
    member ToString : System.IFormatProvider -> string
    static val MaxValue : char
    static val MinValue : char
    static member ConvertFromUtf32 : int -> string
    static member ConvertToUtf32 : char * char -> int
    static member ConvertToUtf32 : string * int -> int
    static member GetNumericValue : char -> float
    static member GetNumericValue : string * int -> float
    static member GetUnicodeCategory : char -> System.Globalization.UnicodeCategory
    static member GetUnicodeCategory : string * int -> System.Globalization.UnicodeCategory
    static member IsControl : char -> bool
    static member IsControl : string * int -> bool
    static member IsDigit : char -> bool
    static member IsDigit : string * int -> bool
    static member IsHighSurrogate : char -> bool
    static member IsHighSurrogate : string * int -> bool
    static member IsLetter : char -> bool
    static member IsLetter : string * int -> bool
    static member IsLetterOrDigit : char -> bool
    static member IsLetterOrDigit : string * int -> bool
    static member IsLowSurrogate : char -> bool
    static member IsLowSurrogate : string * int -> bool
    static member IsLower : char -> bool
    static member IsLower : string * int -> bool
    static member IsNumber : char -> bool
    static member IsNumber : string * int -> bool
    static member IsPunctuation : char -> bool
    static member IsPunctuation : string * int -> bool
    static member IsSeparator : char -> bool
    static member IsSeparator : string * int -> bool
    static member IsSurrogate : char -> bool
    static member IsSurrogate : string * int -> bool
    static member IsSurrogatePair : string * int -> bool
    static member IsSurrogatePair : char * char -> bool
    static member IsSymbol : char -> bool
    static member IsSymbol : string * int -> bool
    static member IsUpper : char -> bool
    static member IsUpper : string * int -> bool
    static member IsWhiteSpace : char -> bool
    static member IsWhiteSpace : string * int -> bool
    static member Parse : string -> char
    static member ToLower : char -> char
    static member ToLower : char * System.Globalization.CultureInfo -> char
    static member ToLowerInvariant : char -> char
    static member ToString : char -> string
    static member ToUpper : char -> char
    static member ToUpper : char * System.Globalization.CultureInfo -> char
    static member ToUpperInvariant : char -> char
    static member TryParse : string * char -> bool
  end

Full name: System.Char

  type: Char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType
Multiple overloads
Char.IsLower(c: char) : bool
Char.IsLower(s: string, index: int) : bool
Multiple overloads
Char.IsUpper(c: char) : bool
Char.IsUpper(s: string, index: int) : bool
Multiple items
val float : 'T -> float (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float

--------------------

type float<'Measure> = float

Full name: Microsoft.FSharp.Core.float<_>

  type: float<'Measure>
  implements: IComparable
  implements: IConvertible
  implements: IFormattable
  implements: IComparable<float<'Measure>>
  implements: IEquatable<float<'Measure>>
  inherits: ValueType


--------------------

type float = Double

Full name: Microsoft.FSharp.Core.float

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
Multiple items
val char : 'T -> char (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.char

--------------------

type char = Char

Full name: Microsoft.FSharp.Core.char

  type: char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType
val separators : string array

Full name: Snippet.separators

  type: string array
  implements: ICloneable
  implements: Collections.IList
  implements: Collections.ICollection
  implements: Collections.IStructuralComparable
  implements: Collections.IStructuralEquatable
  implements: Collections.Generic.IList<string>
  implements: Collections.Generic.ICollection<string>
  implements: seq<string>
  implements: Collections.IEnumerable
  inherits: Array
property Collections.Generic.IDictionary.Keys: Collections.Generic.ICollection<char>
module Seq

from Microsoft.FSharp.Collections
val map : ('T -> 'U) -> seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val c : char

  type: char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType
val sprintf : Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val toArray : seq<'T> -> 'T array

Full name: Microsoft.FSharp.Collections.Seq.toArray
val getFormatters : char list -> char list

Full name: Snippet.getFormatters
val xs : char list

  type: char list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<char>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<char>
  implements: Collections.IEnumerable
val xr : char list

  type: char list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<char>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<char>
  implements: Collections.IEnumerable
val x : char

  type: char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType
Collections.Generic.IDictionary.ContainsKey(key: char) : bool
val sscanf : PrintfFormat<'a,'b,'c,'d,'t> -> string -> 't

Full name: Snippet.sscanf
val pf : PrintfFormat<'a,'b,'c,'d,'t>

  type: PrintfFormat<'a,'b,'c,'d,'t>
  inherits: PrintfFormat<'a,'b,'c,'d>
Multiple items
type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple> =
  class
    inherit PrintfFormat<'Printer,'State,'Residue,'Result>
    new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>
  end

Full name: Microsoft.FSharp.Core.PrintfFormat<_,_,_,_,_>

  type: PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>
  inherits: PrintfFormat<'Printer,'State,'Residue,'Result>


--------------------

type PrintfFormat<'Printer,'State,'Residue,'Result> =
  class
    new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result>
    member Value : string
  end

Full name: Microsoft.FSharp.Core.PrintfFormat<_,_,_,_>
val s : string

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val formatStr : string

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
property PrintfFormat.Value: string
Multiple overloads
String.Replace(oldValue: string, newValue: string) : string
String.Replace(oldChar: char, newChar: char) : string
val constants : string []

  type: string []
  implements: ICloneable
  implements: Collections.IList
  implements: Collections.ICollection
  implements: Collections.IStructuralComparable
  implements: Collections.IStructuralEquatable
  implements: Collections.Generic.IList<string>
  implements: Collections.Generic.ICollection<string>
  implements: seq<string>
  implements: Collections.IEnumerable
  inherits: Array
Multiple overloads
String.Split(separator: char []) : string []
String.Split(separator: string [], options: StringSplitOptions) : string []
String.Split(separator: char [], options: StringSplitOptions) : string []
String.Split(separator: char [], count: int) : string []
String.Split(separator: string [], count: int, options: StringSplitOptions) : string []
String.Split(separator: char [], count: int, options: StringSplitOptions) : string []
type StringSplitOptions =
  | None = 0
  | RemoveEmptyEntries = 1

Full name: System.StringSplitOptions

  type: StringSplitOptions
  inherits: Enum
  inherits: ValueType
field StringSplitOptions.None = 0
val regex : Regex

  type: Regex
  implements: Runtime.Serialization.ISerializable
type Regex =
  class
    new : string -> System.Text.RegularExpressions.Regex
    new : string * System.Text.RegularExpressions.RegexOptions -> System.Text.RegularExpressions.Regex
    member GetGroupNames : unit -> string []
    member GetGroupNumbers : unit -> int []
    member GroupNameFromNumber : int -> string
    member GroupNumberFromName : string -> int
    member IsMatch : string -> bool
    member IsMatch : string * int -> bool
    member Match : string -> System.Text.RegularExpressions.Match
    member Match : string * int -> System.Text.RegularExpressions.Match
    member Match : string * int * int -> System.Text.RegularExpressions.Match
    member Matches : string -> System.Text.RegularExpressions.MatchCollection
    member Matches : string * int -> System.Text.RegularExpressions.MatchCollection
    member Options : System.Text.RegularExpressions.RegexOptions
    member Replace : string * string -> string
    member Replace : string * System.Text.RegularExpressions.MatchEvaluator -> string
    member Replace : string * string * int -> string
    member Replace : string * System.Text.RegularExpressions.MatchEvaluator * int -> string
    member Replace : string * string * int * int -> string
    member Replace : string * System.Text.RegularExpressions.MatchEvaluator * int * int -> string
    member RightToLeft : bool
    member Split : string -> string []
    member Split : string * int -> string []
    member Split : string * int * int -> string []
    member ToString : unit -> string
    static member CacheSize : int with get, set
    static member CompileToAssembly : System.Text.RegularExpressions.RegexCompilationInfo [] * System.Reflection.AssemblyName -> unit
    static member CompileToAssembly : System.Text.RegularExpressions.RegexCompilationInfo [] * System.Reflection.AssemblyName * System.Reflection.Emit.CustomAttributeBuilder [] -> unit
    static member CompileToAssembly : System.Text.RegularExpressions.RegexCompilationInfo [] * System.Reflection.AssemblyName * System.Reflection.Emit.CustomAttributeBuilder [] * string -> unit
    static member Escape : string -> string
    static member IsMatch : string * string -> bool
    static member IsMatch : string * string * System.Text.RegularExpressions.RegexOptions -> bool
    static member Match : string * string -> System.Text.RegularExpressions.Match
    static member Match : string * string * System.Text.RegularExpressions.RegexOptions -> System.Text.RegularExpressions.Match
    static member Matches : string * string -> System.Text.RegularExpressions.MatchCollection
    static member Matches : string * string * System.Text.RegularExpressions.RegexOptions -> System.Text.RegularExpressions.MatchCollection
    static member Replace : string * string * string -> string
    static member Replace : string * string * System.Text.RegularExpressions.MatchEvaluator -> string
    static member Replace : string * string * string * System.Text.RegularExpressions.RegexOptions -> string
    static member Replace : string * string * System.Text.RegularExpressions.MatchEvaluator * System.Text.RegularExpressions.RegexOptions -> string
    static member Split : string * string -> string []
    static member Split : string * string * System.Text.RegularExpressions.RegexOptions -> string []
    static member Unescape : string -> string
  end

Full name: System.Text.RegularExpressions.Regex

  type: Regex
  implements: Runtime.Serialization.ISerializable
Multiple overloads
String.Join(separator: string, values: seq<string>) : string
String.Join<'T>(separator: string, values: seq<'T>) : string
String.Join(separator: string, values: obj []) : string
String.Join(separator: string, value: string []) : string
String.Join(separator: string, value: string [], startIndex: int, count: int) : string
type Array =
  class
    member Clone : unit -> obj
    member CopyTo : System.Array * int -> unit
    member CopyTo : System.Array * int64 -> unit
    member GetEnumerator : unit -> System.Collections.IEnumerator
    member GetLength : int -> int
    member GetLongLength : int -> int64
    member GetLowerBound : int -> int
    member GetUpperBound : int -> int
    member GetValue : int [] -> obj
    member GetValue : int -> obj
    member GetValue : int64 -> obj
    member GetValue : int64 [] -> obj
    member GetValue : int * int -> obj
    member GetValue : int64 * int64 -> obj
    member GetValue : int * int * int -> obj
    member GetValue : int64 * int64 * int64 -> obj
    member Initialize : unit -> unit
    member IsFixedSize : bool
    member IsReadOnly : bool
    member IsSynchronized : bool
    member Length : int
    member LongLength : int64
    member Rank : int
    member SetValue : obj * int -> unit
    member SetValue : obj * int [] -> unit
    member SetValue : obj * int64 -> unit
    member SetValue : obj * int64 [] -> unit
    member SetValue : obj * int * int -> unit
    member SetValue : obj * int64 * int64 -> unit
    member SetValue : obj * int * int * int -> unit
    member SetValue : obj * int64 * int64 * int64 -> unit
    member SyncRoot : obj
    static member AsReadOnly<'T> : 'T [] -> System.Collections.ObjectModel.ReadOnlyCollection<'T>
    static member BinarySearch : System.Array * obj -> int
    static member BinarySearch<'T> : 'T [] * 'T -> int
    static member BinarySearch : System.Array * obj * System.Collections.IComparer -> int
    static member BinarySearch<'T> : 'T [] * 'T * System.Collections.Generic.IComparer<'T> -> int
    static member BinarySearch : System.Array * int * int * obj -> int
    static member BinarySearch<'T> : 'T [] * int * int * 'T -> int
    static member BinarySearch : System.Array * int * int * obj * System.Collections.IComparer -> int
    static member BinarySearch<'T> : 'T [] * int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
    static member Clear : System.Array * int * int -> unit
    static member ConstrainedCopy : System.Array * int * System.Array * int * int -> unit
    static member ConvertAll<'TInput,'TOutput> : 'TInput [] * System.Converter<'TInput,'TOutput> -> 'TOutput []
    static member Copy : System.Array * System.Array * int -> unit
    static member Copy : System.Array * System.Array * int64 -> unit
    static member Copy : System.Array * int * System.Array * int * int -> unit
    static member Copy : System.Array * int64 * System.Array * int64 * int64 -> unit
    static member CreateInstance : System.Type * int -> System.Array
    static member CreateInstance : System.Type * int [] -> System.Array
    static member CreateInstance : System.Type * int64 [] -> System.Array
    static member CreateInstance : System.Type * int * int -> System.Array
    static member CreateInstance : System.Type * int [] * int [] -> System.Array
    static member CreateInstance : System.Type * int * int * int -> System.Array
    static member Exists<'T> : 'T [] * System.Predicate<'T> -> bool
    static member Find<'T> : 'T [] * System.Predicate<'T> -> 'T
    static member FindAll<'T> : 'T [] * System.Predicate<'T> -> 'T []
    static member FindIndex<'T> : 'T [] * System.Predicate<'T> -> int
    static member FindIndex<'T> : 'T [] * int * System.Predicate<'T> -> int
    static member FindIndex<'T> : 'T [] * int * int * System.Predicate<'T> -> int
    static member FindLast<'T> : 'T [] * System.Predicate<'T> -> 'T
    static member FindLastIndex<'T> : 'T [] * System.Predicate<'T> -> int
    static member FindLastIndex<'T> : 'T [] * int * System.Predicate<'T> -> int
    static member FindLastIndex<'T> : 'T [] * int * int * System.Predicate<'T> -> int
    static member ForEach<'T> : 'T [] * System.Action<'T> -> unit
    static member IndexOf : System.Array * obj -> int
    static member IndexOf<'T> : 'T [] * 'T -> int
    static member IndexOf : System.Array * obj * int -> int
    static member IndexOf<'T> : 'T [] * 'T * int -> int
    static member IndexOf : System.Array * obj * int * int -> int
    static member IndexOf<'T> : 'T [] * 'T * int * int -> int
    static member LastIndexOf : System.Array * obj -> int
    static member LastIndexOf<'T> : 'T [] * 'T -> int
    static member LastIndexOf : System.Array * obj * int -> int
    static member LastIndexOf<'T> : 'T [] * 'T * int -> int
    static member LastIndexOf : System.Array * obj * int * int -> int
    static member LastIndexOf<'T> : 'T [] * 'T * int * int -> int
    static member Resize<'T> : 'T [] * int -> unit
    static member Reverse : System.Array -> unit
    static member Reverse : System.Array * int * int -> unit
    static member Sort : System.Array -> unit
    static member Sort<'T> : 'T [] -> unit
    static member Sort : System.Array * System.Array -> unit
    static member Sort : System.Array * System.Collections.IComparer -> unit
    static member Sort<'TKey,'TValue> : 'TKey [] * 'TValue [] -> unit
    static member Sort<'T> : 'T [] * System.Collections.Generic.IComparer<'T> -> unit
    static member Sort<'T> : 'T [] * System.Comparison<'T> -> unit
    static member Sort : System.Array * int * int -> unit
    static member Sort : System.Array * System.Array * System.Collections.IComparer -> unit
    static member Sort<'T> : 'T [] * int * int -> unit
    static member Sort<'TKey,'TValue> : 'TKey [] * 'TValue [] * System.Collections.Generic.IComparer<'TKey> -> unit
    static member Sort : System.Array * System.Array * int * int -> unit
    static member Sort : System.Array * int * int * System.Collections.IComparer -> unit
    static member Sort<'TKey,'TValue> : 'TKey [] * 'TValue [] * int * int -> unit
    static member Sort<'T> : 'T [] * int * int * System.Collections.Generic.IComparer<'T> -> unit
    static member Sort : System.Array * System.Array * int * int * System.Collections.IComparer -> unit
    static member Sort<'TKey,'TValue> : 'TKey [] * 'TValue [] * int * int * System.Collections.Generic.IComparer<'TKey> -> unit
    static member TrueForAll<'T> : 'T [] * System.Predicate<'T> -> bool
  end

Full name: System.Array

  type: Array
  implements: ICloneable
  implements: Collections.IList
  implements: Collections.ICollection
  implements: Collections.IEnumerable
  implements: Collections.IStructuralComparable
  implements: Collections.IStructuralEquatable
val map : ('T -> 'U) -> 'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.map
Regex.Escape(str: string) : string
val formatters : char list

  type: char list
  implements: Collections.IStructuralEquatable
  implements: IComparable<List<char>>
  implements: IComparable
  implements: Collections.IStructuralComparable
  implements: Collections.Generic.IEnumerable<char>
  implements: Collections.IEnumerable
Multiple overloads
String.ToCharArray() : char []
String.ToCharArray(startIndex: int, length: int) : char []
val toList : 'T [] -> 'T list

Full name: Microsoft.FSharp.Collections.Array.toList
val groups : seq<Group>

  type: seq<Group>
  inherits: Collections.IEnumerable
Multiple overloads
Regex.Match(input: string) : Match
Regex.Match(input: string, startat: int) : Match
Regex.Match(input: string, beginning: int, length: int) : Match
val cast : Collections.IEnumerable -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.cast
type Group =
  class
    inherit System.Text.RegularExpressions.Capture
    member Captures : System.Text.RegularExpressions.CaptureCollection
    member Success : bool
    static member Synchronized : System.Text.RegularExpressions.Group -> System.Text.RegularExpressions.Group
  end

Full name: System.Text.RegularExpressions.Group

  type: Group
  inherits: Capture
val skip : int -> seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.skip
val matches : obj array

  type: obj array
  implements: ICloneable
  implements: Collections.IList
  implements: Collections.ICollection
  implements: Collections.IStructuralComparable
  implements: Collections.IStructuralEquatable
  implements: Collections.Generic.IList<obj>
  implements: Collections.Generic.ICollection<obj>
  implements: seq<obj>
  implements: Collections.IEnumerable
  inherits: Array
val map2 : ('T1 -> 'T2 -> 'U) -> seq<'T1> -> seq<'T2> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map2
val g : Group

  type: Group
  inherits: Capture
val f : char

  type: char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType
property Capture.Value: string
property Array.Length: int
type FSharpValue =
  class
    static member GetExceptionFields : exn:obj * ?bindingFlags:Reflection.BindingFlags -> obj []
    static member GetRecordField : record:obj * info:Reflection.PropertyInfo -> obj
    static member GetRecordFields : record:obj * ?bindingFlags:Reflection.BindingFlags -> obj []
    static member GetTupleField : tuple:obj * index:int -> obj
    static member GetTupleFields : tuple:obj -> obj []
    static member GetUnionFields : value:obj * unionType:Type * ?bindingFlags:Reflection.BindingFlags -> UnionCaseInfo * obj []
    static member MakeFunction : functionType:Type * implementation:(obj -> obj) -> obj
    static member MakeRecord : recordType:Type * values:obj [] * ?bindingFlags:Reflection.BindingFlags -> obj
    static member MakeTuple : tupleElements:obj [] * tupleType:Type -> obj
    static member MakeUnion : unionCase:UnionCaseInfo * args:obj [] * ?bindingFlags:Reflection.BindingFlags -> obj
    static member PreComputeRecordConstructor : recordType:Type * ?bindingFlags:Reflection.BindingFlags -> (obj [] -> obj)
    static member PreComputeRecordConstructorInfo : recordType:Type * ?bindingFlags:Reflection.BindingFlags -> Reflection.ConstructorInfo
    static member PreComputeRecordFieldReader : info:Reflection.PropertyInfo -> (obj -> obj)
    static member PreComputeRecordReader : recordType:Type * ?bindingFlags:Reflection.BindingFlags -> (obj -> obj [])
    static member PreComputeTupleConstructor : tupleType:Type -> (obj [] -> obj)
    static member PreComputeTupleConstructorInfo : tupleType:Type -> Reflection.ConstructorInfo * Type option
    static member PreComputeTuplePropertyInfo : tupleType:Type * index:int -> Reflection.PropertyInfo * (Type * int) option
    static member PreComputeTupleReader : tupleType:Type -> (obj -> obj [])
    static member PreComputeUnionConstructor : unionCase:UnionCaseInfo * ?bindingFlags:Reflection.BindingFlags -> (obj [] -> obj)
    static member PreComputeUnionConstructorInfo : unionCase:UnionCaseInfo * ?bindingFlags:Reflection.BindingFlags -> Reflection.MethodInfo
    static member PreComputeUnionReader : unionCase:UnionCaseInfo * ?bindingFlags:Reflection.BindingFlags -> (obj -> obj [])
    static member PreComputeUnionTagMemberInfo : unionType:Type * ?bindingFlags:Reflection.BindingFlags -> Reflection.MemberInfo
    static member PreComputeUnionTagReader : unionType:Type * ?bindingFlags:Reflection.BindingFlags -> (obj -> int)
  end

Full name: Microsoft.FSharp.Reflection.FSharpValue
static member FSharpValue.MakeTuple : tupleElements:obj [] * tupleType:Type -> obj
val typeof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typeof
val a : string

Full name: Snippet.a

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val b : decimal

Full name: Snippet.b

  type: decimal
  implements: IFormattable
  implements: IComparable
  implements: IConvertible
  implements: Runtime.Serialization.IDeserializationCallback
  implements: IComparable<decimal>
  implements: IEquatable<decimal>
  inherits: ValueType
val x : string

Full name: Snippet.x

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val y : string

Full name: Snippet.y

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val z : string

Full name: Snippet.z

  type: string
  implements: IComparable
  implements: ICloneable
  implements: IConvertible
  implements: IComparable<string>
  implements: seq<char>
  implements: Collections.IEnumerable
  implements: IEquatable<string>
val c : bool

Full name: Snippet.c

  type: bool
  implements: IComparable
  implements: IConvertible
  implements: IComparable<bool>
  implements: IEquatable<bool>
  inherits: ValueType
val d : int

Full name: Snippet.d

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val e : int

Full name: Snippet.e

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val f : int

Full name: Snippet.f

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val g : int

Full name: Snippet.g

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val h : int

Full name: Snippet.h

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val i : int

Full name: Snippet.i

  type: int
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int>
  implements: IEquatable<int>
  inherits: ValueType
val j : float

Full name: Snippet.j

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val k : float

Full name: Snippet.k

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val l : float

Full name: Snippet.l

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val m : float

Full name: Snippet.m

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val n : float

Full name: Snippet.n

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val o : float

Full name: Snippet.o

  type: float
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<float>
  implements: IEquatable<float>
  inherits: ValueType
val p : char

Full name: Snippet.p

  type: char
  implements: IComparable
  implements: IConvertible
  implements: IComparable<char>
  implements: IEquatable<char>
  inherits: ValueType

More information

Link: http://fssnip.net/4I
Posted: 2 years ago
Author: Wolfgang Meyer
Tags: sscanf, scanf, parsing, printf