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

Expose the I8 constructor #511

Open
mglch opened this issue Feb 21, 2023 · 2 comments
Open

Expose the I8 constructor #511

mglch opened this issue Feb 21, 2023 · 2 comments

Comments

@mglch
Copy link

mglch commented Feb 21, 2023

The newtype I8 in Data.Text.Foreign does not expose its constructor. Is that intentional?

I would like to use I8 as a semantic distinction to prevent mixing up byte-offsets and character-offsets, in code that ultimately passes the values to takeWord8 and dropWord8.

@Lysxia
Copy link
Contributor

Lysxia commented Jul 11, 2023

I'm not sure whether the constructor is intentionally hidden, but since it's an instance of Integral you can easily convert to and from it with fromIntegral. What you describe is already exactly the purpose of I8 as I understand it. Do you still need the constructor to be exposed?

@phadej
Copy link
Contributor

phadej commented Jul 11, 2023

I'd use Enum instance, as that converts directly to/from Int. Integral goes through Integer, which is a bit excessive.

And indeed Enum instance kind of exposes the structure, so not exposing the constructor doesn't seem to add any value.

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

3 participants