summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Data/StateCodes/ISO31662US.hs7
-rw-r--r--state-codes.cabal2
-rw-r--r--test/Data/StateCodesSpec.hs23
3 files changed, 14 insertions, 18 deletions
diff --git a/src/Data/StateCodes/ISO31662US.hs b/src/Data/StateCodes/ISO31662US.hs
index 126b151..e385c3a 100644
--- a/src/Data/StateCodes/ISO31662US.hs
+++ b/src/Data/StateCodes/ISO31662US.hs
@@ -1,11 +1,11 @@
-- The information used in this module was pulled from the @Wikipedia article
-- about ISO_3166-2:US@: <https://en.wikipedia.org/wiki/ISO_3166-2:US>.
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
--- Only if version 7.8
{-# LANGUAGE PatternGuards #-}
module Data.StateCodes.ISO31662US
@@ -21,7 +21,6 @@ module Data.StateCodes.ISO31662US
, toText
) where
-import Control.Applicative (pure)
import Control.Arrow ((&&&))
import Data.Aeson
import Data.Text (Text)
@@ -29,6 +28,10 @@ import qualified Data.Text as T
import Data.Typeable
import Text.Shakespeare.I18N
+#if !MIN_VERSION_base(4,8,0)
+import Control.Applicative (pure)
+#endif
+
data StateCode = AL -- ^ Alabama
| AK -- ^ Alaska
| AZ -- ^ Arizona
diff --git a/state-codes.cabal b/state-codes.cabal
index 1b45dea..800856a 100644
--- a/state-codes.cabal
+++ b/state-codes.cabal
@@ -1,5 +1,5 @@
name: state-codes
-version: 0.1.2
+version: 0.1.3
synopsis: ISO 3166-2:US state codes and i18n names
description: This package provides the ISO 3166-2:US state codes and i18n names
homepage: https://github.com/acamino/state-codes#README
diff --git a/test/Data/StateCodesSpec.hs b/test/Data/StateCodesSpec.hs
index 9f484a3..7197a0c 100644
--- a/test/Data/StateCodesSpec.hs
+++ b/test/Data/StateCodesSpec.hs
@@ -1,27 +1,20 @@
-{-# LANGUAGE OverloadedStrings #-}
-{-# OPTIONS -fno-warn-orphans #-}
-
module Data.StateCodesSpec where
import Data.Aeson
-import qualified Data.Aeson as A
import Test.Hspec
import Test.Hspec.QuickCheck
import Test.QuickCheck
import Data.StateCodes
-instance Arbitrary StateCode where
- arbitrary = elements [minBound ..]
-
-
spec :: Spec
-spec = do
- prop "fromName . toName" $ forAll arbitrary $ \code ->
- (fromName . toName) code == code
+spec =
+ describe "StateCode" $ do
+ prop "fromName . toName" $ forAll arbitraryBoundedEnum $ \code ->
+ (fromName . toName) code == (code :: StateCode)
- prop "fromText . toText" $ forAll arbitrary $ \code ->
- (fromText . toText) code == code
+ prop "fromText . toText" $ forAll arbitraryBoundedEnum $ \code ->
+ (fromText . toText) code == (code :: StateCode)
- prop "fromJSON . toJSON" $ forAll (arbitrary :: Gen StateCode)$ \code ->
- (fromJSON . toJSON) code == A.Success code
+ prop "decode . encode" $ forAll arbitraryBoundedEnum $ \code ->
+ (decode . encode) code == Just (code :: StateCode)