Skip to content

Abstract interface#17

Open
raphael-proust wants to merge 5 commits intoOCamlPro:masterfrom
raphael-proust:abstract-interface
Open

Abstract interface#17
raphael-proust wants to merge 5 commits intoOCamlPro:masterfrom
raphael-proust:abstract-interface

Conversation

@raphael-proust
Copy link
Copy Markdown

This PR introduces an abstract interface for the Endian* modules. The intent is to allow the use of the endian library as a functor argument. I.e., making the following code valid:

module Mk
  (Endian:
    sig
      include EndianSig.GET
      include EndianSig.SET with type t := t
    end) =
struct
  … <some code using Endian.get_* and Endian.set_*> …
end

module WithBEBytes = Mk (EndianBytes.BigEndian)

Points to discuss:

  • The EndianString modules have deprecated writing functions (they are deprecated in favour of EndianBytes). Should these deprecated functions be removed? I think they should, let me know if you agree/disagree.
  • Currently the type substitution is a bit annoying because it forces additional syntax for the library user. It can be made simpler by (1) removing deprecated functions in EndianString and (2) exposing types in all of the Endian{Bigstring,Bytes,String}.{Big,Little}Endian{,_unsafe}.
  • Should we rename EndianSig.GET (resp EndianSig.SET) into EndianSig.R(respEndianSig.W) and offer a EndianSig.RW` in addition? I'll make an additional commit towards this and we can discuss it there.

@chambart
Copy link
Copy Markdown
Member

Ok that's sensible. I'm going to do a release of a dune version first, then look at this.

  • It might be ok to remove deprecated functions. Those have been deprecated for 3 years now. And the 1.0 branch is going to be maintained for quite some time (probably until the end of life of debian Jessie).

Anyway, I'm not sure I see why you say that removing those function might help with using the library. As any use of this using the added signature is certainly not going to be using unsafe-string.

Also I would prefer explicit names rather than single letters.

@raphael-proust
Copy link
Copy Markdown
Author

I changed to the explicit names.

The FULL helps avoiding the type substitution.

Let me know if there are other improvements that could make it into this MR.

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

Successfully merging this pull request may close these issues.

2 participants