diff --git a/spago.dhall b/spago.dhall index 3eb706e..74d99ed 100644 --- a/spago.dhall +++ b/spago.dhall @@ -1,6 +1,13 @@ { name = "web-intl" , dependencies = - [ "effect", "functions", "js-date", "prelude", "unsafe-coerce" ] + [ "effect" + , "functions" + , "js-date" + , "maybe" + , "nullable" + , "prelude" + , "unsafe-coerce" + ] , packages = ./packages.dhall , sources = [ "src/**/*.purs" ] , license = "MIT" diff --git a/src/Web/Intl/DisplayNames.purs b/src/Web/Intl/DisplayNames.purs index e3612bd..db7026b 100644 --- a/src/Web/Intl/DisplayNames.purs +++ b/src/Web/Intl/DisplayNames.purs @@ -14,6 +14,9 @@ module Web.Intl.DisplayNames import Data.Function.Uncurried (Fn2) import Data.Function.Uncurried as Function.Uncurried +import Data.Maybe (Maybe) +import Data.Nullable (Nullable) +import Data.Nullable as Nullable import Effect (Effect) import Effect.Uncurried (EffectFn2) import Effect.Uncurried as Effect.Uncurried @@ -65,7 +68,7 @@ supportedLocalesOf locales options = Function.Uncurried.runFn2 _supportedLocalesOf locales (Unsafe.Coerce.unsafeCoerce options) foreign import _of - :: Fn2 DisplayNames String String + :: Fn2 DisplayNames String (Nullable String) -of_ :: DisplayNames -> String -> String -of_ = Function.Uncurried.runFn2 _of \ No newline at end of file +of_ :: DisplayNames -> String -> Maybe String +of_ displayNames key = Nullable.toMaybe (Function.Uncurried.runFn2 _of displayNames key) \ No newline at end of file diff --git a/test/Main.purs b/test/Main.purs index 40d4bc6..ffde794 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -5,6 +5,7 @@ import Prelude import Data.Either (Either(..)) import Data.JSDate (JSDate) import Data.JSDate as JSDate +import Data.Maybe (Maybe(..)) import Data.String (Pattern(..), Replacement(..)) import Data.String as String import Effect (Effect) @@ -289,7 +290,7 @@ test_DisplayNames = do Console.log "DisplayNames.of_" Test.assertEqual { actual: DisplayNames.of_ displayNames "en-US" - , expected: "American English" + , expected: Just "American English" } test_ListFormat :: Effect Unit