Engineering Random Bits: F# Generics

This is the first in a series of articles demonstrating some software engineering concepts in F# programming. The vehicle for my demonstrations is RandomBits, which derives random numbers from bits supplied by the ANU Quantum Random Numbers Server. Good pseudo-random number generators are perfectly adequate for almost any random number generation need you may ever encounter, but the application is nonetheless interesting from a software engineering standpoint. It consumes a web service, does bit-twiddling, implements generic functions, and presents a nice set of testing requirements.

F# Generic Functions

RandomBits provides true (not pseudo-random) signed and unsigned 8, 16, 32, and 64 bit random numbers from the bits served up from the Australian National University Centre for Quantum Computation & Communication Technology. As you can well imagine the basic processing for different bit-sized integers is essentially the same, yet most typed languages would limit code sharing among different data types. Chapter 5 of Expert F# 3.0 describes three techniques for writing generic algorithm functions, allowing you to write functions which support all numeric types.

I chose the inlining technique for this project. Take a look at the first snippet:

216:     member inline private this.rndSignRangeSeq (inclLower : 'a) (exlUpper : 'a) length 
217:         (nextZero : 'b) (nextOne : 'b)  (nextSigned : 'a -> 'b) (signed : 'b -> 'a) = 
218:         
219:         let lower = nextSigned inclLower
220:         let range =  (nextSigned exlUpper) - lower
221: 
222:         if range < nextOne then 
223:             invalidArg  "range" (sprintf "%i %i range must be greater than 0" inclLower exlUpper)
224:         if length < 1 then 
225:             invalidArg  "length" (sprintf "%i must be greater than 0" length)
226:         
227:         let upper = (nextSigned exlUpper) - (lower + nextOne)
228: 
229:         seq {for i = 1 to length do
230:                 yield this.randomWalk lower upper nextZero nextOne |> signed
231:              }

rndSignRangeSeq validates user parameters and generates a sequence of signed random numbers of any type from sbyte to int64. Because there are arithmetic operations involved, generically typing the input parameters is not sufficient to use this function for more than one number type. The input parameters operated upon by +, -, &#60 would default to the first number type passed by another function and attempts to use additional types would fail at compile time, but by inlining this member the input parameters stay generic and the F# compiler assigns an implicit constraint that the generic be a type supporting the math operators involved. Mouse-over one of the range delimter parameters (inclLower or exlUpper) and you will see

'a (requires 'a: (byte|inte16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))

Part of the logic (in the succeeding generic function randomWalk, not described in this article) requires casting and computations at the next larger size of number. Note the parameters of type 'b

'b (requires member (-) and comparison and member (+) and member (>>>) and member (<<<))

whose implicit constraints the compiler also derives. When writing the code you just need to keep track of the roles of types 'a and 'b.

This allows simple code that can handle all signed number types. Here are the public members for different kinds of random ranges calling rndSignRangeSeq

489:     (* random numbers in range sequences *)
490: 
491:     ///random signed 8-bit integer in range inclusive of lower and exclusive of upper, seq of length
492:     member this.RndSByteSeq (inclLower, exlUpper, length)  = 
493:         this.rndSignRangeSeq inclLower exlUpper length 0s 1s (int16) (sbyte)
... 
498: 
499:     ///random signed 16-bit integer in range inclusive of lower and exclusive of upper, seq of length
500:     member this.RndInt16Seq (inclLower, exlUpper, length)  = 
501:         this.rndSignRangeSeq inclLower exlUpper length 0 1 (int32) (int16)
... 
506: 
507:     ///random signed 32-bit integer in range inclusive of lower and exclusive of upper, seq of length
508:     member this.RndInt32Seq (inclLower, exlUpper, length)  = 
509:         this.rndSignRangeSeq inclLower exlUpper length 0L 1L (int64) (int)
... 
513:         this.rndUnsignRangeSeq inclLower exlUpper length 0u 1u
514: 
515:     ///random signed 64-bit integer in range inclusive of lower and exclusive of upper, seq of length 
516:     member this.RndInt64Seq (inclLower, exlUpper, length) = 
517:         this.rndSignRangeSeq inclLower exlUpper length 0I 1I (this.bigint) (int64)

val int : 'T -> int (requires member op_Explicit)

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

val int64 : 'T -> int64 (requires member op_Explicit)

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

val this : RandomBits

  type: RandomBits
  implements: IDisposable

member private RandomBits.waiting : unit -> unit

Full name: RandomBits.waiting

val loop : (int -> unit)
val x : int

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

val not : bool -> bool

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

property BackgroundWorker.IsBusy: bool
BackgroundWorker.CancelAsync() : unit
BackgroundWorker.RunWorkerAsync() : unit
BackgroundWorker.RunWorkerAsync(argument: obj) : unit
namespace System.Threading
type Thread =
  class
    inherit System.Runtime.ConstrainedExecution.CriticalFinalizerObject
    new : System.Threading.ThreadStart -> System.Threading.Thread
    new : System.Threading.ThreadStart * int -> System.Threading.Thread
    new : System.Threading.ParameterizedThreadStart -> System.Threading.Thread
    new : System.Threading.ParameterizedThreadStart * int -> System.Threading.Thread
    member Abort : unit -> unit
    member Abort : obj -> unit
    member ApartmentState : System.Threading.ApartmentState with get, set
    member CurrentCulture : System.Globalization.CultureInfo with get, set
    member CurrentUICulture : System.Globalization.CultureInfo with get, set
    member DisableComObjectEagerCleanup : unit -> unit
    member ExecutionContext : System.Threading.ExecutionContext
    member GetApartmentState : unit -> System.Threading.ApartmentState
    member GetCompressedStack : unit -> System.Threading.CompressedStack
    member GetHashCode : unit -> int
    member Interrupt : unit -> unit
    member IsAlive : bool
    member IsBackground : bool with get, set
    member IsThreadPoolThread : bool
    member Join : unit -> unit
    member Join : int -> bool
    member Join : System.TimeSpan -> bool
    member ManagedThreadId : int
    member Name : string with get, set
    member Priority : System.Threading.ThreadPriority with get, set
    member Resume : unit -> unit
    member SetApartmentState : System.Threading.ApartmentState -> unit
    member SetCompressedStack : System.Threading.CompressedStack -> unit
    member Start : unit -> unit
    member Start : obj -> unit
    member Suspend : unit -> unit
    member ThreadState : System.Threading.ThreadState
    member TrySetApartmentState : System.Threading.ApartmentState -> bool
    static member AllocateDataSlot : unit -> System.LocalDataStoreSlot
    static member AllocateNamedDataSlot : string -> System.LocalDataStoreSlot
    static member BeginCriticalRegion : unit -> unit
    static member BeginThreadAffinity : unit -> unit
    static member CurrentContext : System.Runtime.Remoting.Contexts.Context
    static member CurrentPrincipal : System.Security.Principal.IPrincipal with get, set
    static member CurrentThread : System.Threading.Thread
    static member EndCriticalRegion : unit -> unit
    static member EndThreadAffinity : unit -> unit
    static member FreeNamedDataSlot : string -> unit
    static member GetData : System.LocalDataStoreSlot -> obj
    static member GetDomain : unit -> System.AppDomain
    static member GetDomainID : unit -> int
    static member GetNamedDataSlot : string -> System.LocalDataStoreSlot
    static member MemoryBarrier : unit -> unit
    static member ResetAbort : unit -> unit
    static member SetData : System.LocalDataStoreSlot * obj -> unit
    static member Sleep : int -> unit
    static member Sleep : System.TimeSpan -> unit
    static member SpinWait : int -> unit
    static member VolatileRead : System.Byte -> System.Byte
    static member VolatileRead : int16 -> int16
    static member VolatileRead : int -> int
    static member VolatileRead : int64 -> int64
    static member VolatileRead : System.SByte -> System.SByte
    static member VolatileRead : uint16 -> uint16
    static member VolatileRead : uint32 -> uint32
    static member VolatileRead : System.IntPtr -> System.IntPtr
    static member VolatileRead : System.UIntPtr -> System.UIntPtr
    static member VolatileRead : uint64 -> uint64
    static member VolatileRead : float32 -> float32
    static member VolatileRead : float -> float
    static member VolatileRead : obj -> obj
    static member VolatileWrite : System.Byte * System.Byte -> unit
    static member VolatileWrite : int16 * int16 -> unit
    static member VolatileWrite : int * int -> unit
    static member VolatileWrite : int64 * int64 -> unit
    static member VolatileWrite : System.SByte * System.SByte -> unit
    static member VolatileWrite : uint16 * uint16 -> unit
    static member VolatileWrite : uint32 * uint32 -> unit
    static member VolatileWrite : System.IntPtr * System.IntPtr -> unit
    static member VolatileWrite : System.UIntPtr * System.UIntPtr -> unit
    static member VolatileWrite : uint64 * uint64 -> unit
    static member VolatileWrite : float32 * float32 -> unit
    static member VolatileWrite : float * float -> unit
    static member VolatileWrite : obj * obj -> unit
    static member Yield : unit -> bool
  end

Full name: System.Threading.Thread

  type: Threading.Thread
  implements: Runtime.InteropServices._Thread
  inherits: Runtime.ConstrainedExecution.CriticalFinalizerObject

Threading.Thread.Sleep(timeout: TimeSpan) : unit
Threading.Thread.Sleep(millisecondsTimeout: int) : unit
member private RandomBits.next64 : unit -> uint64

Full name: RandomBits.next64

val success : bool

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

val ru64 : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

ConcurrentQueue.TryDequeue(result: byref<uint64>) : bool
member private RandomBits.waiting : unit -> unit
member private RandomBits.nextBit : unit -> bool

Full name: RandomBits.nextBit

member private RandomBits.next64 : unit -> uint64
static member private RandomBits.unsignedOfBit : displ:int -> bitOffset:int -> bit64:uint64 -> bitSize:int -> zero:'a -> one:'a -> 'a (requires member ( <<< ))

Full name: RandomBits.unsignedOfBit

val displ : int

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

val bitOffset : int

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

val bit64 : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

val bitSize : int

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

val zero : 'a (requires member ( <<< ))
val one : 'a (requires member ( <<< ))
val x' : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

member private RandomBits.bitsToNumber : bitSize:int -> zero:'a -> one:'a -> 'g

Full name: RandomBits.bitsToNumber

val zero : 'a
val one : 'a
val loop : ('g -> int -> 'g)
val acc : 'g
val offset : int

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

member private RandomBits.bitsToNumber2 : bitSize:int -> zero:'a -> one:'a -> bit64:'d -> displ:'e -> 'f

Full name: RandomBits.bitsToNumber2

val bit64 : 'd
val displ : 'e
val loop : ('f -> int -> 'f)
val acc : 'f
member private RandomBits.randomWalk : lower:'a -> upper:'a -> zero:'a -> one:'a -> 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))

Full name: RandomBits.randomWalk

val lower : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val upper : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val zero : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val one : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val pwr : int

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

val loop : ('a -> int -> int) (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val u : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val acc : int

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

val u' : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val loop : ('a -> int -> 'a) (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val acc : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val pwrDec : int

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

member private RandomBits.nextBit : unit -> bool
val loop2 : ('a -> 'a) (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val x : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
val myRnd : 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
member private RandomBits.rndInRange : inclLower:'a -> exlUpper:'a -> zero:'a -> one:'a -> 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))

Full name: RandomBits.rndInRange

val inclLower : 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
val exlUpper : 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
val zero : 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
val one : 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
val range : 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
member private RandomBits.randomWalk : lower:'a -> upper:'a -> zero:'a -> one:'a -> 'a (requires member ( >>> ) and comparison and member ( + ) and member ( <<< ))
member private RandomBits.rndSignInRange : inclLower:'a -> exlUpper:'a -> uZero:'c -> nextOne:'b -> nextSigned:('a -> 'b) -> nextSigned2:('c -> 'b) -> signed:('b -> 'a) -> unsigned:('b -> 'c) -> uConv:('c * 'c -> 'c) -> 'a (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ))

Full name: RandomBits.rndSignInRange

val inclLower : 'a (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))
val exlUpper : 'a (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))
val uZero : 'c
val nextOne : 'b (requires member ( – ) and comparison and member ( + ))
val nextSigned : ('a -> 'b) (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ))
val nextSigned2 : ('c -> 'b) (requires member ( – ) and comparison and member ( + ))
val signed : ('b -> 'a) (requires member ( – ) and comparison and member ( + ) and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))
val unsigned : ('b -> 'c) (requires member ( – ) and comparison and member ( + ))
val uConv : ('c * 'c -> 'c)
val lower : 'b (requires member ( – ) and comparison and member ( + ))
val range : 'b (requires member ( – ) and comparison and member ( + ))
val invalidArg : string -> string -> 'T

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

val sprintf : Printf.StringFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf

member private RandomBits.rndSeq : length:int -> bitSize:int -> zero:'a -> one:'a -> signed:('a -> 'b) -> seq<'b>

Full name: RandomBits.rndSeq

val length : int

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

val signed : ('a -> 'b)
val ptr : int ref

  type: int ref
  implements: Collections.IStructuralEquatable
  implements: IComparable<Ref<int>>
  implements: IComparable
  implements: Collections.IStructuralComparable

Multiple items
val ref : 'T -> 'T ref

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

——————–
type 'T ref = Ref<'T>

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

  type: 'T ref
  implements: Collections.IStructuralEquatable
  implements: IComparable<Ref<'T>>
  implements: IComparable
  implements: Collections.IStructuralComparable

val n' : int

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

val i : int

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

member private RandomBits.bitsToNumber2 : bitSize:int -> zero:'a -> one:'a -> bit64:'d -> displ:'e -> 'f
member private RandomBits.rndSignRangeSeq : inclLower:'a -> exlUpper:'a -> length:int -> nextZero:'b -> nextOne:'b -> nextSigned:('a -> 'b) -> signed:('b -> 'a) -> seq<'a> (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))

Full name: RandomBits.rndSignRangeSeq

val nextZero : 'b (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
val nextOne : 'b (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
val nextSigned : ('a -> 'b) (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
val signed : ('b -> 'a) (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ) and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))
val lower : 'b (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
val range : 'b (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
val upper : 'b (requires member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
member private RandomBits.rndUnsignRangeSeq : inclLower:'a -> exlUpper:'a -> length:int -> zero:'a -> one:'a -> seq<'a> (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))

Full name: RandomBits.rndUnsignRangeSeq

val inclLower : 'a (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
val exlUpper : 'a (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
val zero : 'a (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
val one : 'a (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
val range : 'a (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
member private RandomBits.rndInRange : inclLower:'a -> exlUpper:'a -> zero:'a -> one:'a -> 'a (requires member ( – ) and comparison and member ( >>> ) and member ( + ) and member ( <<< ))
member private RandomBits.rndSignUniqueSeq : inclLower:'a -> exlUpper:'a -> length:int -> nextZero:'b -> nextOne:'b -> nextSigned:('a -> 'b) -> signed:('b -> 'a) -> seq<'a> (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))

Full name: RandomBits.rndSignUniqueSeq

val nextZero : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val nextOne : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val nextSigned : ('a -> 'b) (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val signed : ('b -> 'a) (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ) and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint))
val lower : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val upper : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val range : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val count : 'b ref (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))

  type: 'b ref
  implements: Collections.IStructuralEquatable
  implements: IComparable<Ref<'b>>
  implements: IComparable
  implements: Collections.IStructuralComparable

val h : 'a ref

  type: 'a ref
  implements: Collections.IStructuralEquatable
  implements: IComparable<Ref<'a>>
  implements: IComparable
  implements: Collections.IStructuralComparable

val x : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val x' : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val fold : ('State -> 'T -> 'State) -> 'State -> seq<'T> -> 'State

Full name: Microsoft.FSharp.Collections.Seq.fold

val t : 'b (requires comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
member private RandomBits.rndUnsignUniqueSeq : inclLower:'a -> exlUpper:'a -> length:int -> zero:'a -> one:'a -> seq<'a> (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))

Full name: RandomBits.rndUnsignUniqueSeq

val inclLower : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val exlUpper : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val zero : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val one : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val range : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val count : 'a ref (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))

  type: 'a ref
  implements: Collections.IStructuralEquatable
  implements: IComparable<Ref<'a>>
  implements: IComparable
  implements: Collections.IStructuralComparable

val x : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val x' : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
val t : 'a (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
Multiple items
member private RandomBits.bigint : x:int64 -> BigInteger

Full name: RandomBits.bigint

——————–
type bigint = BigInteger

Full name: Microsoft.FSharp.Core.bigint

  type: bigint
  implements: IFormattable
  implements: IComparable
  implements: IComparable<BigInteger>
  implements: IEquatable<BigInteger>
  inherits: ValueType

val x : int64

  type: int64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int64>
  implements: IEquatable<int64>
  inherits: ValueType

type BigInteger =
  struct
    new : int -> System.Numerics.BigInteger
    new : uint32 -> System.Numerics.BigInteger
    new : int64 -> System.Numerics.BigInteger
    new : uint64 -> System.Numerics.BigInteger
    new : float32 -> System.Numerics.BigInteger
    new : float -> System.Numerics.BigInteger
    new : decimal -> System.Numerics.BigInteger
    new : System.Byte [] -> System.Numerics.BigInteger
    member CompareTo : int64 -> int
    member CompareTo : uint64 -> int
    member CompareTo : System.Numerics.BigInteger -> int
    member CompareTo : obj -> int
    member Equals : obj -> bool
    member Equals : int64 -> bool
    member Equals : uint64 -> bool
    member Equals : System.Numerics.BigInteger -> bool
    member GetHashCode : unit -> int
    member IsEven : bool
    member IsOne : bool
    member IsPowerOfTwo : bool
    member IsZero : bool
    member Sign : int
    member ToByteArray : unit -> System.Byte []
    member ToString : unit -> string
    member ToString : System.IFormatProvider -> string
    member ToString : string -> string
    member ToString : string * System.IFormatProvider -> string
    static member Abs : System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Add : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Compare : System.Numerics.BigInteger * System.Numerics.BigInteger -> int
    static member DivRem : System.Numerics.BigInteger * System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Divide : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member GreatestCommonDivisor : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Log : System.Numerics.BigInteger -> float
    static member Log : System.Numerics.BigInteger * float -> float
    static member Log10 : System.Numerics.BigInteger -> float
    static member Max : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Min : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member MinusOne : System.Numerics.BigInteger
    static member ModPow : System.Numerics.BigInteger * System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Multiply : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Negate : System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member One : System.Numerics.BigInteger
    static member Parse : string -> System.Numerics.BigInteger
    static member Parse : string * System.Globalization.NumberStyles -> System.Numerics.BigInteger
    static member Parse : string * System.IFormatProvider -> System.Numerics.BigInteger
    static member Parse : string * System.Globalization.NumberStyles * System.IFormatProvider -> System.Numerics.BigInteger
    static member Pow : System.Numerics.BigInteger * int -> System.Numerics.BigInteger
    static member Remainder : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member Subtract : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
    static member TryParse : string * System.Numerics.BigInteger -> bool
    static member TryParse : string * System.Globalization.NumberStyles * System.IFormatProvider * System.Numerics.BigInteger -> bool
    static member Zero : System.Numerics.BigInteger
  end

Full name: System.Numerics.BigInteger

  type: BigInteger
  implements: IFormattable
  implements: IComparable
  implements: IComparable<BigInteger>
  implements: IEquatable<BigInteger>
  inherits: ValueType

member private RandomBits.bigintU : x:uint64 -> BigInteger

Full name: RandomBits.bigintU

val x : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

val t : bool

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

event BackgroundWorker.RunWorkerCompleted: IEvent<RunWorkerCompletedEventHandler,RunWorkerCompletedEventArgs>
member IObservable.Add : callback:('T -> unit) -> unit
member private RandomBits.ANU_BlockCount : int

Full name: RandomBits.ANU_BlockCount

member private RandomBits.ANU_Url : string

Full name: RandomBits.ANU_Url

member private RandomBits.CacheLength : int

Full name: RandomBits.CacheLength

property ConcurrentQueue.Count: int
member private RandomBits.Consume64Count : int64

Full name: RandomBits.Consume64Count

member private RandomBits.MaxCache : int

Full name: RandomBits.MaxCache

member private RandomBits.MaxPersistCache : int

Full name: RandomBits.MaxPersistCache

member private RandomBits.PersistCacheLength : int

Full name: RandomBits.PersistCacheLength

member private RandomBits.PersistPath : string

Full name: RandomBits.PersistPath

member private RandomBits.ReusePeristCache : bool

Full name: RandomBits.ReusePeristCache

member private RandomBits.RndBool : unit -> bool

Full name: RandomBits.RndBool

random bool

member private RandomBits.RndSByte : unit -> sbyte

Full name: RandomBits.RndSByte

random signed 8-bit integer

val sbyte : 'T -> sbyte (requires member op_Explicit)

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

member private RandomBits.bitsToNumber : bitSize:int -> zero:'a -> one:'a -> 'g
member private RandomBits.RndByte : unit -> 'c

Full name: RandomBits.RndByte

random unsigned 8-bit integer

member private RandomBits.RndInt16 : unit -> int16

Full name: RandomBits.RndInt16

random signed 16-bit integer

val int16 : 'T -> int16 (requires member op_Explicit)

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

member private RandomBits.RndUint16 : unit -> 'b

Full name: RandomBits.RndUint16

random unsigned 16-bit integer

member private RandomBits.RndInt32 : unit -> int32

Full name: RandomBits.RndInt32

random signed 32-bit integer

val int32 : 'T -> int32 (requires member op_Explicit)

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

member private RandomBits.RndUint32 : unit -> 'a

Full name: RandomBits.RndUint32

random unsigned 32-bit integer

member private RandomBits.RndInt64 : unit -> int64

Full name: RandomBits.RndInt64

random signed 64-bit integer

member private RandomBits.RndUint64 : unit -> uint64

Full name: RandomBits.RndUint64

random unsigned 64-bit integer

member private RandomBits.RndSByte : inclLower:sbyte * exlUpper:sbyte -> sbyte

Full name: RandomBits.RndSByte

random signed 8-bit integer in range inclusive of lower and exclusive of upper

val inclLower : sbyte

  type: sbyte
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<sbyte>
  implements: IEquatable<sbyte>
  inherits: ValueType

val exlUpper : sbyte

  type: sbyte
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<sbyte>
  implements: IEquatable<sbyte>
  inherits: ValueType

member private RandomBits.rndSignInRange : inclLower:'a -> exlUpper:'a -> uZero:'c -> nextOne:'b -> nextSigned:('a -> 'b) -> nextSigned2:('c -> 'b) -> signed:('b -> 'a) -> unsigned:('b -> 'c) -> uConv:('c * 'c -> 'c) -> 'a (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ))
Multiple items
val byte : 'T -> byte (requires member op_Explicit)

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

——————–
type byte = Byte

Full name: Microsoft.FSharp.Core.byte

  type: byte
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<byte>
  implements: IEquatable<byte>
  inherits: ValueType

member private RandomBits.RndByte : unit -> 'c

random unsigned 8-bit integer
member private RandomBits.RndByte : inclLower:byte * exlUpper:byte -> byte

random unsigned 8-bit integer in range inclusive of lower and exclusive of upper

member private RandomBits.RndByte : inclLower:byte * exlUpper:byte -> byte

Full name: RandomBits.RndByte

random unsigned 8-bit integer in range inclusive of lower and exclusive of upper

val inclLower : byte

  type: byte
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<byte>
  implements: IEquatable<byte>
  inherits: ValueType

val exlUpper : byte

  type: byte
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<byte>
  implements: IEquatable<byte>
  inherits: ValueType

member private RandomBits.RndInt16 : inclLower:int16 * exlUpper:int16 -> int16

Full name: RandomBits.RndInt16

random signed 16-bit integer in range inclusive of lower and exclusive of upper

val inclLower : int16

  type: int16
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int16>
  implements: IEquatable<int16>
  inherits: ValueType

val exlUpper : int16

  type: int16
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int16>
  implements: IEquatable<int16>
  inherits: ValueType

Multiple items
val uint16 : 'T -> uint16 (requires member op_Explicit)

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

——————–
type uint16 = UInt16

Full name: Microsoft.FSharp.Core.uint16

  type: uint16
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint16>
  implements: IEquatable<uint16>
  inherits: ValueType

member private RandomBits.RndUint16 : unit -> 'b

random unsigned 16-bit integer
member private RandomBits.RndUint16 : inclLower:uint16 * exlUpper:uint16 -> uint16

random unsigned 16-bit integer in range inclusive of lower and exclusive of upper

member private RandomBits.RndUint16 : inclLower:uint16 * exlUpper:uint16 -> uint16

Full name: RandomBits.RndUint16

random unsigned 16-bit integer in range inclusive of lower and exclusive of upper

val inclLower : uint16

  type: uint16
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint16>
  implements: IEquatable<uint16>
  inherits: ValueType

val exlUpper : uint16

  type: uint16
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint16>
  implements: IEquatable<uint16>
  inherits: ValueType

member private RandomBits.RndInt32 : inclLower:int32 * exlUpper:int32 -> int32

Full name: RandomBits.RndInt32

random signed 32-bit integer in range inclusive of lower and exclusive of upper

val inclLower : int32

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

val exlUpper : int32

  type: int32
  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

member private RandomBits.RndUint32 : unit -> 'a

random unsigned 32-bit integer
member private RandomBits.RndUint32 : inclLower:uint32 * exlUpper:uint32 -> uint32

random unsigned 32-bit integer in range inclusive of lower and exclusive of upper

member private RandomBits.RndUint32 : inclLower:uint32 * exlUpper:uint32 -> uint32

Full name: RandomBits.RndUint32

random unsigned 32-bit integer in range inclusive of lower and exclusive of upper

val inclLower : uint32

  type: uint32
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint32>
  implements: IEquatable<uint32>
  inherits: ValueType

val exlUpper : uint32

  type: uint32
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint32>
  implements: IEquatable<uint32>
  inherits: ValueType

member private RandomBits.RndInt64 : inclLower:int64 * exlUpper:int64 -> int64

Full name: RandomBits.RndInt64

random signed 64-bit integer in range inclusive of lower and exclusive of upper

val inclLower : int64

  type: int64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int64>
  implements: IEquatable<int64>
  inherits: ValueType

val exlUpper : int64

  type: int64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<int64>
  implements: IEquatable<int64>
  inherits: ValueType

val lower : BigInteger

  type: BigInteger
  implements: IFormattable
  implements: IComparable
  implements: IComparable<BigInteger>
  implements: IEquatable<BigInteger>
  inherits: ValueType

member private RandomBits.bigint : x:int64 -> BigInteger
val range : BigInteger

  type: BigInteger
  implements: IFormattable
  implements: IComparable
  implements: IComparable<BigInteger>
  implements: IEquatable<BigInteger>
  inherits: ValueType

member private RandomBits.bigintU : x:uint64 -> BigInteger
member private RandomBits.RndUint64 : unit -> uint64

random unsigned 64-bit integer
member private RandomBits.RndUint64 : inclLower:uint64 * exlUpper:uint64 -> uint64

random unsigned 64-bit integer in range inclusive of lower and exclusive of upper

member private RandomBits.RndUint64 : inclLower:uint64 * exlUpper:uint64 -> uint64

Full name: RandomBits.RndUint64

random unsigned 64-bit integer in range inclusive of lower and exclusive of upper

val inclLower : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

val exlUpper : uint64

  type: uint64
  implements: IComparable
  implements: IFormattable
  implements: IConvertible
  implements: IComparable<uint64>
  implements: IEquatable<uint64>
  inherits: ValueType

member private RandomBits.RndBoolSeq : length:int -> seq<bool>

Full name: RandomBits.RndBoolSeq

random bool seq of length

member private RandomBits.RndSByteSeq : length:int -> seq<sbyte>

Full name: RandomBits.RndSByteSeq

random signed 8-bit integer seq of length

member private RandomBits.rndSeq : length:int -> bitSize:int -> zero:'a -> one:'a -> signed:('a -> 'b) -> seq<'b>
member private RandomBits.RndByteSeq : length:int -> seq<byte>

Full name: RandomBits.RndByteSeq

random unsigned 8-bit integer seq of length

member private RandomBits.RndInt16Seq : length:int -> seq<int16>

Full name: RandomBits.RndInt16Seq

random signed 16-bit integer seq of length

member private RandomBits.RndUint16Seq : length:int -> seq<uint16>

Full name: RandomBits.RndUint16Seq

random unsigned 16-bit integer seq of length

member private RandomBits.RndInt32Seq : length:int -> seq<int>

Full name: RandomBits.RndInt32Seq

random signed 32-bit integer seq of length

member private RandomBits.RndUint32Seq : length:int -> seq<uint32>

Full name: RandomBits.RndUint32Seq

random unsigned 32-bit integer seq of length

member private RandomBits.RndInt64Seq : length:int -> seq<int64>

Full name: RandomBits.RndInt64Seq

random signed 64-bit integer seq of length

member private RandomBits.RndUint64Seq : length:int -> seq<uint64>

Full name: RandomBits.RndUint64Seq

random unsigned 64-bit integer seq of length

member private RandomBits.RndSByteSeq : inclLower:sbyte * exlUpper:sbyte * length:int -> seq<sbyte>

Full name: RandomBits.RndSByteSeq

random signed 8-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.rndSignRangeSeq : inclLower:'a -> exlUpper:'a -> length:int -> nextZero:'b -> nextOne:'b -> nextSigned:('a -> 'b) -> signed:('b -> 'a) -> seq<'a> (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( – ) and comparison and member ( + ) and member ( >>> ) and member ( <<< ))
member private RandomBits.RndByteSeq : inclLower:byte * exlUpper:byte * length:int -> seq<byte>

Full name: RandomBits.RndByteSeq

random unsigned 8-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.rndUnsignRangeSeq : inclLower:'a -> exlUpper:'a -> length:int -> zero:'a -> one:'a -> seq<'a> (requires member ( – ) and comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member ( >>> ) and member ( + ) and member ( <<< ))
member private RandomBits.RndInt16Seq : inclLower:int16 * exlUpper:int16 * length:int -> seq<int16>

Full name: RandomBits.RndInt16Seq

random signed 16-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndUint16Seq : inclLower:uint16 * exlUpper:uint16 * length:int -> seq<uint16>

Full name: RandomBits.RndUint16Seq

random unsigned 16-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndInt32Seq : inclLower:int * exlUpper:int * length:int -> seq<int>

Full name: RandomBits.RndInt32Seq

random usigned 32-bit integer in range inclusive of lower and exclusive of upper, seq of length

val inclLower : int

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

val exlUpper : int

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

member private RandomBits.RndUint32Seq : inclLower:uint32 * exlUpper:uint32 * length:int -> seq<uint32>

Full name: RandomBits.RndUint32Seq

random unsigned 32-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndInt64Seq : inclLower:int64 * exlUpper:int64 * length:int -> seq<int64>

Full name: RandomBits.RndInt64Seq

random usigned 64-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndUint64Seq : inclLower:uint64 * exlUpper:uint64 * length:int -> seq<uint64>

Full name: RandomBits.RndUint64Seq

random unsigned 64-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndSByteUniqueSeq : inclLower:sbyte * exlUpper:sbyte * length:int -> seq<sbyte>

Full name: RandomBits.RndSByteUniqueSeq

random unique usigned 8-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.rndSignUniqueSeq : inclLower:'a -> exlUpper:'a -> length:int -> nextZero:'b -> nextOne:'b -> nextSigned:('a -> 'b) -> signed:('b -> 'a) -> seq<'a> (requires 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and comparison and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
member private RandomBits.RndByteUniqueSeq : inclLower:byte * exlUpper:byte * length:int -> seq<byte>

Full name: RandomBits.RndByteUniqueSeq

random unique unsigned 8-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.rndUnsignUniqueSeq : inclLower:'a -> exlUpper:'a -> length:int -> zero:'a -> one:'a -> seq<'a> (requires comparison and 'a : (byte|int16|int32|int64|sbyte|uint16|uint32|uint64|nativeint|unativeint) and member op_Explicit and member ( >>> ) and member ( <<< ) and member ( – ) and member ( + ))
member private RandomBits.RndInt16UniqueSeq : inclLower:int16 * exlUpper:int16 * length:int -> seq<int16>

Full name: RandomBits.RndInt16UniqueSeq

random unique signed 16-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndUint16UniqueSeq : inclLower:uint16 * exlUpper:uint16 * length:int -> seq<uint16>

Full name: RandomBits.RndUint16UniqueSeq

random unique unsigned 16-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndInt32UniqueSeq : inclLower:int * exlUpper:int * length:int -> seq<int>

Full name: RandomBits.RndInt32UniqueSeq

random unique signed 32-bit integer in range inclusive of lower and exclusive of upper, seq of length

member private RandomBits.RndUint32UniqueSeq : inclLower:uint32 * exlUpper:uint32 * length:int -> seq<uint32>

Full name: RandomBits.RndUint32UniqueSeq

random unique unsigned 32-bit integer in range inclusive of lower and exclusive of upper, seq of length

Multiple items
type IDisposable =
  interface
    member Dispose : unit -> unit
  end

Full name: System.IDisposable

——————–
IDisposable

override private RandomBits.Dispose : unit -> unit

Full name: RandomBits.Dispose

Component.Dispose() : unit

And that’s almost all there is to generating random sequences of different types. In a future article I’ll show you the generic bit twiddling involved.

End Note: Formatted F# Snippets

As well applying my best engineering chops to the application, I’m taking this opportunity to better engineer this blog. For the first time I’ve formatted F# code snippets using Tomas Petricek’s FSharp.Formatting code formatter. Not only is the code color-coded like in an IDE, but mouse-over tool tips work just like intellisense.

FSharp.Formatting requires FSharp.CompilerBinding, then generating formatted F# with tool tip intellisense is as easy as running the following:

 1: #r "FSharp.CodeFormat.dll"
 2: open FSharp.CodeFormat
 3: open System.IO
 4: 
 5: let fsharpCompiler = "C:\\Program Files\\Microsoft F#\\v4.0\\FSharp.Compiler.dll"
 6: let asm = System.Reflection.Assembly.LoadFile(fsharpCompiler)
 7: let formatAgent = FSharp.CodeFormat.CodeFormatAgent(asm)
 8: 
 9: let source = File.ReadAllText("C:\\Users\Jack\\Documents\\Scripts\\RandomBits.fs")
10: 
11: let snippets, errors = formatAgent.ParseSource("C:\\Users\Jack\\Documents\\Scripts\\RandomBits.fs", source.Trim())
12: let res = FSharp.CodeFormat.CodeFormat.FormatHtml(snippets, "fstipsA")
13: 
14: let wr = new StreamWriter("C:\\Users\Jack\\Documents\\Scripts\\RandomBits.output")
15: for snip in res.SnippetsHtml do
16:       wr.WriteLine(snip.Title)
17:       wr.WriteLine(snip.Html + "\n")
18: wr.WriteLine("\n\n<!-- GENERATED TOOL TIPS -->")
19: wr.Write(res.ToolTipHtml)
20: wr.Dispose();;

namespace FSharp
module CodeFormat

from FSharp

namespace System
namespace System.IO
val fsharpCompiler : string

Full name: FSharp.CodeFormat.fsharpCompiler

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

val asm : System.Reflection.Assembly

Full name: FSharp.CodeFormat.asm

  type: System.Reflection.Assembly
  implements: System.Runtime.InteropServices._Assembly
  implements: System.Security.IEvidenceFactory
  implements: System.Reflection.ICustomAttributeProvider
  implements: System.Runtime.Serialization.ISerializable

namespace System.Reflection
type Assembly =
  class
    member CodeBase : string
    member CreateInstance : string -> obj
    member CreateInstance : string * bool -> obj
    member CreateInstance : string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj [] * System.Globalization.CultureInfo * obj [] -> obj
    member EntryPoint : System.Reflection.MethodInfo
    member Equals : obj -> bool
    member EscapedCodeBase : string
    member Evidence : System.Security.Policy.Evidence
    member FullName : string
    member GetCustomAttributes : bool -> obj []
    member GetCustomAttributes : System.Type * bool -> obj []
    member GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
    member GetExportedTypes : unit -> System.Type []
    member GetFile : string -> System.IO.FileStream
    member GetFiles : unit -> System.IO.FileStream []
    member GetFiles : bool -> System.IO.FileStream []
    member GetHashCode : unit -> int
    member GetLoadedModules : unit -> System.Reflection.Module []
    member GetLoadedModules : bool -> System.Reflection.Module []
    member GetManifestResourceInfo : string -> System.Reflection.ManifestResourceInfo
    member GetManifestResourceNames : unit -> string []
    member GetManifestResourceStream : string -> System.IO.Stream
    member GetManifestResourceStream : System.Type * string -> System.IO.Stream
    member GetModule : string -> System.Reflection.Module
    member GetModules : unit -> System.Reflection.Module []
    member GetModules : bool -> System.Reflection.Module []
    member GetName : unit -> System.Reflection.AssemblyName
    member GetName : bool -> System.Reflection.AssemblyName
    member GetObjectData : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> unit
    member GetReferencedAssemblies : unit -> System.Reflection.AssemblyName []
    member GetSatelliteAssembly : System.Globalization.CultureInfo -> System.Reflection.Assembly
    member GetSatelliteAssembly : System.Globalization.CultureInfo * System.Version -> System.Reflection.Assembly
    member GetType : string -> System.Type
    member GetType : string * bool -> System.Type
    member GetType : string * bool * bool -> System.Type
    member GetTypes : unit -> System.Type []
    member GlobalAssemblyCache : bool
    member HostContext : int64
    member ImageRuntimeVersion : string
    member IsDefined : System.Type * bool -> bool
    member IsDynamic : bool
    member IsFullyTrusted : bool
    member LoadModule : string * System.Byte [] -> System.Reflection.Module
    member LoadModule : string * System.Byte [] * System.Byte [] -> System.Reflection.Module
    member Location : string
    member ManifestModule : System.Reflection.Module
    member PermissionSet : System.Security.PermissionSet
    member ReflectionOnly : bool
    member SecurityRuleSet : System.Security.SecurityRuleSet
    member ToString : unit -> string
    static member CreateQualifiedName : string * string -> string
    static member GetAssembly : System.Type -> System.Reflection.Assembly
    static member GetCallingAssembly : unit -> System.Reflection.Assembly
    static member GetEntryAssembly : unit -> System.Reflection.Assembly
    static member GetExecutingAssembly : unit -> System.Reflection.Assembly
    static member Load : string -> System.Reflection.Assembly
    static member Load : System.Reflection.AssemblyName -> System.Reflection.Assembly
    static member Load : System.Byte [] -> System.Reflection.Assembly
    static member Load : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member Load : System.Reflection.AssemblyName * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member Load : System.Byte [] * System.Byte [] -> System.Reflection.Assembly
    static member Load : System.Byte [] * System.Byte [] * System.Security.SecurityContextSource -> System.Reflection.Assembly
    static member Load : System.Byte [] * System.Byte [] * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member LoadFile : string -> System.Reflection.Assembly
    static member LoadFile : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member LoadFrom : string -> System.Reflection.Assembly
    static member LoadFrom : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member LoadFrom : string * System.Byte [] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> System.Reflection.Assembly
    static member LoadFrom : string * System.Security.Policy.Evidence * System.Byte [] * System.Configuration.Assemblies.AssemblyHashAlgorithm -> System.Reflection.Assembly
    static member LoadWithPartialName : string -> System.Reflection.Assembly
    static member LoadWithPartialName : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
    static member ReflectionOnlyLoad : string -> System.Reflection.Assembly
    static member ReflectionOnlyLoad : System.Byte [] -> System.Reflection.Assembly
    static member ReflectionOnlyLoadFrom : string -> System.Reflection.Assembly
    static member UnsafeLoadFrom : string -> System.Reflection.Assembly
  end

Full name: System.Reflection.Assembly

  type: System.Reflection.Assembly
  implements: System.Runtime.InteropServices._Assembly
  implements: System.Security.IEvidenceFactory
  implements: System.Reflection.ICustomAttributeProvider
  implements: System.Runtime.Serialization.ISerializable

System.Reflection.Assembly.LoadFile(path: string) : System.Reflection.Assembly
val formatAgent : CodeFormatAgent

Full name: FSharp.CodeFormat.formatAgent

namespace FSharp.CodeFormat
type CodeFormatAgent =
  class
    new : fsharpCompiler:System.Reflection.Assembly -> CodeFormatAgent
    member AsyncParseSource : file:string * source:string * ?options:string * ?defines:string -> Async<Snippet [] * SourceError []>
    member ParseSource : file:string * source:string * ?options:string * ?defines:string -> Snippet [] * SourceError []
    member ParseSourceAsync : file:string * source:string * options:string * defines:string -> System.Threading.Tasks.Task<Snippet [] * SourceError []>
  end

Full name: FSharp.CodeFormat.CodeFormatAgent

val source : string

Full name: FSharp.CodeFormat.source

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

type File =
  class
    static member AppendAllLines : string * System.Collections.Generic.IEnumerable<string> -> unit
    static member AppendAllLines : string * System.Collections.Generic.IEnumerable<string> * System.Text.Encoding -> unit
    static member AppendAllText : string * string -> unit
    static member AppendAllText : string * string * System.Text.Encoding -> unit
    static member AppendText : string -> System.IO.StreamWriter
    static member Copy : string * string -> unit
    static member Copy : string * string * bool -> unit
    static member Create : string -> System.IO.FileStream
    static member Create : string * int -> System.IO.FileStream
    static member Create : string * int * System.IO.FileOptions -> System.IO.FileStream
    static member Create : string * int * System.IO.FileOptions * System.Security.AccessControl.FileSecurity -> System.IO.FileStream
    static member CreateText : string -> System.IO.StreamWriter
    static member Decrypt : string -> unit
    static member Delete : string -> unit
    static member Encrypt : string -> unit
    static member Exists : string -> bool
    static member GetAccessControl : string -> System.Security.AccessControl.FileSecurity
    static member GetAccessControl : string * System.Security.AccessControl.AccessControlSections -> System.Security.AccessControl.FileSecurity
    static member GetAttributes : string -> System.IO.FileAttributes
    static member GetCreationTime : string -> System.DateTime
    static member GetCreationTimeUtc : string -> System.DateTime
    static member GetLastAccessTime : string -> System.DateTime
    static member GetLastAccessTimeUtc : string -> System.DateTime
    static member GetLastWriteTime : string -> System.DateTime
    static member GetLastWriteTimeUtc : string -> System.DateTime
    static member Move : string * string -> unit
    static member Open : string * System.IO.FileMode -> System.IO.FileStream
    static member Open : string * System.IO.FileMode * System.IO.FileAccess -> System.IO.FileStream
    static member Open : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare -> System.IO.FileStream
    static member OpenRead : string -> System.IO.FileStream
    static member OpenText : string -> System.IO.StreamReader
    static member OpenWrite : string -> System.IO.FileStream
    static member ReadAllBytes : string -> System.Byte []
    static member ReadAllLines : string -> string []
    static member ReadAllLines : string * System.Text.Encoding -> string []
    static member ReadAllText : string -> string
    static member ReadAllText : string * System.Text.Encoding -> string
    static member ReadLines : string -> System.Collections.Generic.IEnumerable<string>
    static member ReadLines : string * System.Text.Encoding -> System.Collections.Generic.IEnumerable<string>
    static member Replace : string * string * string -> unit
    static member Replace : string * string * string * bool -> unit
    static member SetAccessControl : string * System.Security.AccessControl.FileSecurity -> unit
    static member SetAttributes : string * System.IO.FileAttributes -> unit
    static member SetCreationTime : string * System.DateTime -> unit
    static member SetCreationTimeUtc : string * System.DateTime -> unit
    static member SetLastAccessTime : string * System.DateTime -> unit
    static member SetLastAccessTimeUtc : string * System.DateTime -> unit
    static member SetLastWriteTime : string * System.DateTime -> unit
    static member SetLastWriteTimeUtc : string * System.DateTime -> unit
    static member WriteAllBytes : string * System.Byte [] -> unit
    static member WriteAllLines : string * string [] -> unit
    static member WriteAllLines : string * System.Collections.Generic.IEnumerable<string> -> unit
    static member WriteAllLines : string * string [] * System.Text.Encoding -> unit
    static member WriteAllLines : string * System.Collections.Generic.IEnumerable<string> * System.Text.Encoding -> unit
    static member WriteAllText : string * string -> unit
    static member WriteAllText : string * string * System.Text.Encoding -> unit
  end

Full name: System.IO.File

File.ReadAllText(path: string) : string
File.ReadAllText(path: string, encoding: System.Text.Encoding) : string
val snippets : Snippet []

Full name: FSharp.CodeFormat.snippets

  type: Snippet []
  implements: System.ICloneable
  implements: System.Collections.IList
  implements: System.Collections.ICollection
  implements: System.Collections.IStructuralComparable
  implements: System.Collections.IStructuralEquatable
  implements: System.Collections.Generic.IList<Snippet>
  implements: System.Collections.Generic.ICollection<Snippet>
  implements: seq<Snippet>
  implements: System.Collections.IEnumerable
  inherits: System.Array

val errors : SourceError []

Full name: FSharp.CodeFormat.errors

  type: SourceError []
  implements: System.ICloneable
  implements: System.Collections.IList
  implements: System.Collections.ICollection
  implements: System.Collections.IStructuralComparable
  implements: System.Collections.IStructuralEquatable
  implements: System.Collections.Generic.IList<SourceError>
  implements: System.Collections.Generic.ICollection<SourceError>
  implements: seq<SourceError>
  implements: System.Collections.IEnumerable
  inherits: System.Array

member CodeFormatAgent.ParseSource : file:string * source:string * ?options:string * ?defines:string -> Snippet [] * SourceError []
System.String.Trim() : string
System.String.Trim(trimChars: char []) : string
val res : FormattedHtml

Full name: FSharp.CodeFormat.res

type CodeFormat =
  class
    static member CreateAgent : fsharpCompiler:System.Reflection.Assembly -> CodeFormatAgent
    static member FormatHtml : snippets:Snippet [] * prefix:string -> FormattedHtml
    static member FormatHtml : snippets:Snippet [] * prefix:string * addLines:bool * addErrors:bool -> FormattedHtml
    static member FormatHtml : snippets:Snippet [] * prefix:string * openTag:string * closeTag:string * addLines:bool * addErrors:bool -> FormattedHtml
  end

Full name: FSharp.CodeFormat.CodeFormat

static member CodeFormat.FormatHtml : snippets:Snippet [] * prefix:string -> FormattedHtml
static member CodeFormat.FormatHtml : snippets:Snippet [] * prefix:string * addLines:bool * addErrors:bool -> FormattedHtml
static member CodeFormat.FormatHtml : snippets:Snippet [] * prefix:string * openTag:string * closeTag:string * addLines:bool * addErrors:bool -> FormattedHtml
val wr : StreamWriter

Full name: FSharp.CodeFormat.wr

  type: StreamWriter
  implements: System.IDisposable
  inherits: TextWriter
  inherits: System.MarshalByRefObject

type StreamWriter =
  class
    inherit System.IO.TextWriter
    new : System.IO.Stream -> System.IO.StreamWriter
    new : System.IO.Stream * System.Text.Encoding -> System.IO.StreamWriter
    new : System.IO.Stream * System.Text.Encoding * int -> System.IO.StreamWriter
    new : string -> System.IO.StreamWriter
    new : string * bool -> System.IO.StreamWriter
    new : string * bool * System.Text.Encoding -> System.IO.StreamWriter
    new : string * bool * System.Text.Encoding * int -> System.IO.StreamWriter
    member AutoFlush : bool with get, set
    member BaseStream : System.IO.Stream
    member Close : unit -> unit
    member Encoding : System.Text.Encoding
    member Flush : unit -> unit
    member Write : char -> unit
    member Write : char [] -> unit
    member Write : string -> unit
    member Write : char [] * int * int -> unit
    static val Null : System.IO.StreamWriter
  end

Full name: System.IO.StreamWriter

  type: StreamWriter
  implements: System.IDisposable
  inherits: TextWriter
  inherits: System.MarshalByRefObject

val snip : FormattedSnippet
property FormattedHtml.SnippetsHtml: FormattedSnippet []
TextWriter.WriteLine() : unit
   (+0 other overloads)
TextWriter.WriteLine(value: obj) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: string) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: decimal) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: float) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: float32) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: uint64) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: int64) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: uint32) : unit
   (+0 other overloads)
TextWriter.WriteLine(value: int) : unit
   (+0 other overloads)
property FormattedSnippet.Title: string
property FormattedSnippet.Html: string
TextWriter.Write(value: obj) : unit
   (+0 other overloads)
TextWriter.Write(value: string) : unit
   (+0 other overloads)
TextWriter.Write(value: decimal) : unit
   (+0 other overloads)
TextWriter.Write(value: float) : unit
   (+0 other overloads)
TextWriter.Write(value: float32) : unit
   (+0 other overloads)
TextWriter.Write(value: uint64) : unit
   (+0 other overloads)
TextWriter.Write(value: int64) : unit
   (+0 other overloads)
TextWriter.Write(value: uint32) : unit
   (+0 other overloads)
TextWriter.Write(value: int) : unit
   (+0 other overloads)
TextWriter.Write(value: bool) : unit
   (+0 other overloads)
property FormattedHtml.ToolTipHtml: string
TextWriter.Dispose() : unit

The output required minimal editing for posting into WordPress. Don’t forget to add the FSharp.Formatting CSS and javascript to your site.

FSharp.Formatting is a great resource for promoting F# programming. Not only does it make your code examples look like they are in an IDE, but it makes them more informative. I encourage everyone posting F# articles to use this resource.

FSharp.Formatting Update

Tomas just released documentation updates to his project:

F# Formatting: Documentation tools

F# Formatting: Code formatting

2 thoughts on “Engineering Random Bits: F# Generics

  1. Pingback: F# Weekly #52, 2012 – New Year Edition « Sergey Tihon's Blog

  2. It’s very enlightening article. I came from a C# background and I trying to get closer to functional world (through F#).

    Now F# is first .NET citizen and it’s not acceptable not to know it.

    I love how this article because highlights the way F# can be expressive and concise; after all less code to maintain let you concentrate on real problems and let you craft more solid code.

    I hope to see continuation and other article like this.

    Regards, Giacomo

Leave a Reply to Giacomo Stelluti Scala Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>