3 people like it.

Quick Positive Infinity

A simple trick for defining positive infinity semantics.

1: 
2: 
3: 
4: 
5: 
type Neg<'T when 'T : comparison> = NegativeInfinity | N of 'T
type Pos<'T when 'T : comparison> = P of 'T | PositiveInfinity

N "hello" > NegativeInfinity
P 2 < PositiveInfinity
union case Neg.NegativeInfinity: Neg<'T>
union case Neg.N: 'T -> Neg<'T>
type Pos<'T (requires comparison)> =
  | P of 'T
  | PositiveInfinity

Full name: Script.Pos<_>
union case Pos.P: 'T -> Pos<'T>
union case Pos.PositiveInfinity: Pos<'T>
Raw view Test code New version

More information

Link:http://fssnip.net/jO
Posted:10 years ago
Author:Eirik Tsarpalis
Tags: positive infinity