[Ur] MY_ORD = resolving eq class instance / functor?

Marc Weber marco-oweber at gmx.de
Mon Nov 28 07:00:02 EST 2011


How to make this work?

Trying to understand how classes must be used:

signature MY_ORD = sig
  class strict_less
  val lt : t ::: Type -> strict_less t -> t -> t -> bool
  val le : t ::: Type -> strict_less t -> t -> t -> bool
end

structure My_Ord : MY_ORD = struct
  class strict_less a = a -> a -> bool
  fun lt [a] (f: strict_less a) (x:a) (y:a) = f x y
  (* causing Can't resolve type class instance 
     Class constraint:  Basis.eq a
  *)
  fun le [a] (f: strict_less a) (x:a) (y:a) = f x y || x = y
end

The le implementation does not know which eq implementation to use ?
Is using functor the way to go?

I can't trivially apply the max sample from: http://www.impredicative.com/ur/tutorial/intro.html

Marc Weber



More information about the Ur mailing list