Version française
Home     About     Download     Resources     Contact us    
Browse thread
[newbie] Define and use records in sum types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael Welsh Duggan <md5i@c...>
Subject: Recursive Sets?
I have been trying to create a recursive type which can express sets
of itself.  The following code is not meant to be correct (it isn't),
but hopefully expresses the sort of thing I want to do.  Can someone
throw some ideas at me?

type foo = 
  | A | B 
  | Set of FooSet.t

module OrderedFoos =
  struct
    type t = foo
    let compare (a:t) (b:t) = compare a b
  end

module FooSet = Set.Make(OrderedFoos)

-- 
Michael Duggan
(md5i@cs.cmu.edu)