Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interoperability with the integers package #3

Open
yallop opened this issue May 22, 2017 · 0 comments
Open

Interoperability with the integers package #3

yallop opened this issue May 22, 2017 · 0 comments

Comments

@yallop
Copy link

yallop commented May 22, 2017

For easy interoperability it would be helpful to have the following type equalities in the interface:

module Usane :
sig
  module Uint8 : 
  sig
    type t = Unsigned.UInt8.t
    (* ... *)
  end

  module Uint16 : 
  sig
    type t = Unsigned.UInt16.t
    (* ... *)
  end

  module Uint32 : 
  sig
    type t = Unsigned.UInt32.t
    (* ... *)
  end

  module Uint64 : 
  sig
    type t = Unsigned.UInt64.t
    (* ... *)
  end
end

rather than the current situation:

module Usane :
sig
  module Uint8 : 
  sig
    type t = int
    (* ... *)
  end

  module Uint16 : 
  sig
    type t = int
    (* ... *)
  end

  module Uint32 : 
  sig
    type t = int32
    (* ... *)
  end

  module Uint64 : 
  sig
    type t = int64
    (* ... *)
  end
end

Besides interoperability, there'd be an added bonus: polymorphic comparison (Pervasives.compare, Pervasives.(<)) would work as expected on Uint32.t and Uint64.t. At present, large positive numbers of those types are represented as negative numbers, and so comparison behaves unexpectedly.

Previous discussion: yallop/ocaml-integers#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant