Skip to content

Instantly share code, notes, and snippets.

@t0yv0
Created February 9, 2011 10:32
Show Gist options
  • Select an option

  • Save t0yv0/818276 to your computer and use it in GitHub Desktop.

Select an option

Save t0yv0/818276 to your computer and use it in GitHub Desktop.
module NFA =
[<CustomEquality>]
[<CustomComparison>]
type State<'T> =
| Match
| Branch of Pair<'T>
| Read of int * ('T -> bool) * State<'T>
member this.Key =
match this with
| Match -> 0
| Branch x -> x.k
| Read (i, _, _) -> i
override this.Equals other =
match other with
| :? State<'T> as o ->
this.Key = o.Key
| _ ->
false
override this.GetHashCode() =
this.Key
interface IComparable with
member this.CompareTo other =
compare (hash other) this.Key
and Pair<'T> =
{
mutable k : int
mutable x : State<'T>
y : State<'T>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment