Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPort simple Char functions from JavaScript to Elm #130
Conversation
evancz
reviewed
Jan 22, 2015
src/Char.elm
| {-| True for ASCII hexadecimal digits `[0-9a-fA-F]`. -} | ||
| isHexDigit : Char -> Bool | ||
| isHexDigit = Native.Char.isHexDigit | ||
| isHexDigit char = | ||
| isDigit char || isBetween 'a' 'f' char || isBetween 'A' 'Z' char |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jonathanhefner
reviewed
Jan 23, 2015
src/Char.elm
| isBetween : Char -> Char -> Char -> Bool | ||
| isBetween low high char = | ||
| let code = toCode char | ||
| in (code >= toCode low) && (code <= toCode high) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jonathanhefner
Jan 23, 2015
Contributor
The Basics module isn't auto-imported here, so (&&), (>=), and (<=) are undefined.
Is it safe to import Basics (..)? I assume the reason to not do so is to avoid circular dependencies...? If that's the case, is it uncouth to use Native.Basics.and, etc?
jonathanhefner
Jan 23, 2015
Contributor
The Basics module isn't auto-imported here, so (&&), (>=), and (<=) are undefined.
Is it safe to import Basics (..)? I assume the reason to not do so is to avoid circular dependencies...? If that's the case, is it uncouth to use Native.Basics.and, etc?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Jan 23, 2015
Member
I'd just import the functions in question: import Basics ((&&), (>=), (<=))
It is fine as long as the tests run. If there's a circular dependency, it'll just endlessly initialize modules until some piece of technology tells you to stop.
evancz
Jan 23, 2015
Member
I'd just import the functions in question: import Basics ((&&), (>=), (<=))
It is fine as long as the tests run. If there's a circular dependency, it'll just endlessly initialize modules until some piece of technology tells you to stop.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Looks great, thank you! |
jonathanhefner commentedJan 22, 2015
I'm not sure if this is wanted or not, but I figure it doesn't hurt to offer.
I ported the Native.Char functions that do not use the JavaScript standard lib to pure Elm. My reasons for doing so: