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

Elm 0.18 compatibility #4

Merged
merged 5 commits into from Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ node_js:
- lts/*
- stable
install:
- npm install -g standard elm@0.17 elm-test@0.17
- npm install -g standard elm@0.18 elm-test@0.18
- elm-package install -y
- pushd tests && elm-package install -y && popd
script:
Expand Down
6 changes: 3 additions & 3 deletions elm-package.json
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "2.0.0",
"summary": "Bindings to JavaScript Internationalization API",
"repository": "https://github.com/vanwagonet/elm-intl.git",
"license": "BSD3",
Expand All @@ -16,7 +16,7 @@
],
"native-modules": true,
"dependencies": {
"elm-lang/core": "4.0.5 <= v < 5.0.0"
"elm-lang/core": "5.1.1 <= v < 6.0.0"
},
"elm-version": "0.17.1 <= v < 0.18.0"
"elm-version": "0.18.0 <= v < 0.19.0"
}
86 changes: 44 additions & 42 deletions src/Intl/Collator.elm
@@ -1,16 +1,17 @@
module Intl.Collator exposing
( Collator
, fromLocale
, fromOptions
, compare
, Options
, Usage(Sort, Search)
, Sensitivity(Base, Accent, Case, Variant)
, CaseFirst(Upper, Lower, Default)
, defaults
, resolvedOptions
, supportedLocalesOf
)
module Intl.Collator
exposing
( Collator
, fromLocale
, fromOptions
, compare
, Options
, Usage(Sort, Search)
, Sensitivity(Base, Accent, Case, Variant)
, CaseFirst(Upper, Lower, Default)
, defaults
, resolvedOptions
, supportedLocalesOf
)

{-| A library for comparing strings in a language sensitve way. This module
binds to [Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator).
Expand Down Expand Up @@ -40,7 +41,8 @@ import Intl.Locale exposing (Locale, en)

{-| A Collator object, for comparing strings in a language sensitive way.
-}
type Collator = Collator
type Collator
= Collator


{-| Create a Collator using rules from the specified language
Expand All @@ -49,7 +51,7 @@ type Collator = Collator
-}
fromLocale : Locale -> Collator
fromLocale =
Native.Intl.Collator.fromLocale
Native.Intl.Collator.fromLocale


{-| Create a Collator using rules from the language and other options.
Expand All @@ -69,7 +71,7 @@ fromLocale =
-}
fromOptions : Options -> Collator
fromOptions =
Native.Intl.Collator.fromOptions
Native.Intl.Collator.fromOptions


{-| Compare two Strings according to the sort order of the Collator.
Expand All @@ -78,26 +80,26 @@ fromOptions =
-}
compare : Collator -> String -> String -> Order
compare =
Native.Intl.Collator.compare
Native.Intl.Collator.compare


{-| An Options record, containing the possible settings for a Collator object.
-}
type alias Options =
{ locale: Locale
, usage: Usage
, sensitivity: Sensitivity
, ignorePunctuation: Bool
, numeric: Bool
, caseFirst: CaseFirst
}
{ locale : Locale
, usage : Usage
, sensitivity : Sensitivity
, ignorePunctuation : Bool
, numeric : Bool
, caseFirst : CaseFirst
}


{-| Whether the comparison is for sorting or for searching for matching strings.
-}
type Usage
= Sort
| Search
= Sort
| Search


{-| Which differences in the strings should lead to non-zero result values.
Expand All @@ -114,19 +116,19 @@ Possible values are:
consideration. Examples: `a ≠ b`, `a ≠ á`, `a ≠ A`.
-}
type Sensitivity
= Base
| Accent
| Case
| Variant
= Base
| Accent
| Case
| Variant


{-| Whether upper case or lower case should sort first, or use the default order
for the language.
-}
type CaseFirst
= Upper
| Lower
| Default
= Upper
| Lower
| Default


{-| Returns the default options. This is helpful if you only care to change a
Expand All @@ -138,13 +140,13 @@ few options.
-}
defaults : Options
defaults =
{ locale = en
, usage = Sort
, sensitivity = Variant
, ignorePunctuation = False
, numeric = False
, caseFirst = Default
}
{ locale = en
, usage = Sort
, sensitivity = Variant
, ignorePunctuation = False
, numeric = False
, caseFirst = Default
}


{-| Returns the locale and collation options computed when the Collator was
Expand All @@ -157,7 +159,7 @@ created.
-}
resolvedOptions : Collator -> Options
resolvedOptions =
Native.Intl.Collator.resolvedOptions
Native.Intl.Collator.resolvedOptions


{-| Returns a list from the provided languages that are supported without having
Expand All @@ -174,4 +176,4 @@ to fall back to the runtime's default language.
-}
supportedLocalesOf : List Locale -> List Locale
supportedLocalesOf =
Native.Intl.Collator.supportedLocalesOf
Native.Intl.Collator.supportedLocalesOf
70 changes: 44 additions & 26 deletions src/Intl/Currency.elm
@@ -1,9 +1,15 @@
module Intl.Currency exposing
( Currency
, fromCurrencyCode
, toCurrencyCode
, usd, eur, jpy, gbp, chf, cad
)
module Intl.Currency
exposing
( Currency
, fromCurrencyCode
, toCurrencyCode
, usd
, eur
, jpy
, gbp
, chf
, cad
)

{-| A Currency is used to the display numeric data as money. Note that
`NumberFormat` does *not* do exchange currency conversion, it only uses the
Expand All @@ -25,8 +31,8 @@ import String exposing (toUpper)

{-| The Currency type holds a valid ISO 4217 currency code.
-}
type Currency =
Currency String
type Currency
= Currency String


{-| Checks the string as a valid currency code, and returns a currency if it is.
Expand All @@ -43,10 +49,10 @@ the code you provided.
-}
fromCurrencyCode : String -> Maybe Currency
fromCurrencyCode code =
if contains (regex "^[A-Za-z]{3}$") code then
Just (Currency (toUpper code))
else
Nothing
if contains (regex "^[A-Za-z]{3}$") code then
Just (Currency (toUpper code))
else
Nothing


{-| Gets the string currency code from a Currency
Expand All @@ -55,36 +61,48 @@ fromCurrencyCode code =
-}
toCurrencyCode : Currency -> String
toCurrencyCode currency =
case currency of
Currency tag -> tag
case currency of
Currency tag ->
tag


{-| United States Dollar -}
{-| United States Dollar
-}
usd : Currency
usd =
Currency "USD"
Currency "USD"


{-| Euro -}
{-| Euro
-}
eur : Currency
eur =
Currency "EUR"
Currency "EUR"

{-| Japanese Yen -}

{-| Japanese Yen
-}
jpy : Currency
jpy =
Currency "JPY"
Currency "JPY"


{-| Pound Sterling -}
{-| Pound Sterling
-}
gbp : Currency
gbp =
Currency "GBP"
Currency "GBP"


{-| Swiss Franc -}
{-| Swiss Franc
-}
chf : Currency
chf =
Currency "CHF"
Currency "CHF"

{-| Canadian Dollar -}

{-| Canadian Dollar
-}
cad : Currency
cad =
Currency "CAD"
Currency "CAD"