Hacker News new | ask | show | jobs
by catnaroek 3620 days ago
Seems a lot more cumbersome than the direct ML solution:

    signature ORD =
    sig
      type t
      val <= : t * t -> t
    end
    
    functor RedBlackSet (E : ORD) :> SET =
    struct
      type elem = E.t
      
      datatype set
        = Empty
        | Red of set * elem * set
        | Black of set * elem * set
      
      (* ... *)
    end
    
    structure Foo = RedBlackSet (Int)
    structure Bar = RedBlackSet (Backwards (Int))
    
    (* Foo.set and Bar.set are different abstract types! *)
1 comments

That is more elegant! But do you think they're functionally more or less equivalent?
Assuming you don't mind plumbing value-level proxies all over the place, it's indeed functionally equivalent.