Skip to content

Remove ElmType instances of non-32bit int types#17

Open
expipiplus1 wants to merge 1 commit intokrisajenkins:masterfrom
expipiplus1:int-instances
Open

Remove ElmType instances of non-32bit int types#17
expipiplus1 wants to merge 1 commit intokrisajenkins:masterfrom
expipiplus1:int-instances

Conversation

@expipiplus1
Copy link

As requested, here's this change with a more thorough explanation.

Elm's Int type is a 32bit two's complement integer. The exact size of
Haskell's Int type is unspecified. Having instances for integral types
which don't have an isomorphism to Elm types allows for lossy
conversions when moving data between the two languages. For example
sending an Elm Int to a Haskell function with type Int8 -> Int8 will
only work with 8 bit values and raise an error for any out of range
values. By only providing instances for Int32 the user is forced into
being more careful with how they marshall integer types between Haskell
and Elm.

See https://github.com/elm-lang/core/issues/742#issuecomment-257484290
for information on the specifics of Elm's Int type.

Elm's `Int` type is a 32bit two's complement integer. The exact size of
Haskell's `Int` type is unspecified. Having instances for integral types
which don't have an isomorphism to Elm types allows for lossy
conversions when moving data between the two languages. For example
sending an Elm Int to a Haskell function with type `Int8 -> Int8` will
only work with 8 bit values and raise an error for any out of range
values. By only providing instances for Int32 the user is forced into
being more careful with how they marshall integer types between Haskell
and Elm.

See https://github.com/elm-lang/core/issues/742#issuecomment-257484290
for information on the specifics of Elm's Int type.
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.

1 participant