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

Add Char.toInt with tests #413

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@bradurani

bradurani commented Sep 28, 2015

Adds Char.toInt which seems like it should be there based on what's in the other classes. I discovered there's no easy way to map a Char such as '1' to the Int 1. You'd think '1' |> toString |> String.toInt would do it but toString '1' returns "'1'"!
I can't find an easy way to convert a Char to a String at all. I thought about adding a method for that, but I wouldn't know what to call it, since toString is taken.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Sep 28, 2015

Contributor

About getting from Char to Int: Isn't that what Char.toCode is for? (Or at the very least, you could implement your Char.toInt in Elm by using the existing Char.toCode without doing any native stuff as you do in your pull request.)

About getting from a Char to a String: It seems you have overlooked the existence of String.fromChar.

Contributor

jvoigtlaender commented Sep 28, 2015

About getting from Char to Int: Isn't that what Char.toCode is for? (Or at the very least, you could implement your Char.toInt in Elm by using the existing Char.toCode without doing any native stuff as you do in your pull request.)

About getting from a Char to a String: It seems you have overlooked the existence of String.fromChar.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Sep 29, 2015

Contributor

I'm closing this issue.

@bradurani, if you want to propose addition of Char.toInt, please:

  • Do so via a pull request to https://github.com/zeckalpha/char-extra. This is the current standard practice of suggesting completely new stuff (rather than fixing existing stuff) for core: collecting it into *-extra libraries first.
  • Try doing it without using native stuff. The existing Char.toCode should enable you to implement Char.toInt in pure Elm.

Concerning "Char.toString", see my previous comment.

Contributor

jvoigtlaender commented Sep 29, 2015

I'm closing this issue.

@bradurani, if you want to propose addition of Char.toInt, please:

  • Do so via a pull request to https://github.com/zeckalpha/char-extra. This is the current standard practice of suggesting completely new stuff (rather than fixing existing stuff) for core: collecting it into *-extra libraries first.
  • Try doing it without using native stuff. The existing Char.toCode should enable you to implement Char.toInt in pure Elm.

Concerning "Char.toString", see my previous comment.

@bradurani

This comment has been minimized.

Show comment
Hide comment
@bradurani

bradurani Sep 29, 2015

Makes since. I'm getting the hang of all this. Thanks for explaining @jvoigtlaender

bradurani commented Sep 29, 2015

Makes since. I'm getting the hang of all this. Thanks for explaining @jvoigtlaender

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment