Large Int Set in sml

I am having the following problem in sml : I want to create a set using signature IntListSet

, but int

I want to use instead large int

. Is there a way to fix this?

Thank you, waiting for your reply.

+3


source to share


1 answer


You can use a functor ListSetFn

. From the documentation, you will find:

functor ListSetFn (ORD_KEY) : ORD_SET

      

This is to say that it ListSetFn

is a functor that accepts a structure that satisfies a signature ORD_KEY

, which you can find in the documentation as:

type ord_key
val compare : (ord_key * ord_key) -> order 

      



Basically, you need to create a structure that satisfies the signature ORD_KEY

, for example:

structure LargeIntKey : ORD_KEY = 
struct 
  type ord_key = LargeInt.int 
  val compare = LargeInt.compare
end

      

And then you can instantiate the LargeInt

functor ListSetFn

by doing:

 structure LargeIntSet = ListSetFn(LargeIntKey)

      

+3


source







All Articles