Sal-laS
Sal-laS

Reputation: 11649

Meaning of "==>" syntax in F#

Consider the following code in F#

let rec ordered xs = 
    match xs with
      | [] | [_]        -> true
      | x1 :: x2 :: xs'  -> x1 <= x2 && ordered (x2 :: xs')

and then

let rec insert x xs = 
    match xs with
    | []      -> [x]
    | y :: ys -> if x <= y then x :: y :: ys 
                 else           y :: insert x ys

and finally

let insertKeepsOrder (x : int) xs = ordered xs ==> ordered (insert x xs)

What i can not understand is the ==> meanning in the last line!!!

What is it?

Upvotes: 2

Views: 2685

Answers (1)

porges
porges

Reputation: 30580

The ==> operator is part of FsCheck. It is used to express a property that should hold only if some condition is true.

So in your example:

let insertKeepsOrder (x : int) xs = ordered xs ==> ordered (insert x xs)

This means ordered (insert x xs) should be true only if ordered xs is true.

You can read more about this in the "Conditional Properties" section of the FsCheck documentation.

Upvotes: 6

Related Questions