aboutsummaryrefslogtreecommitdiff
path: root/lib/Malodivo/Types/District.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Malodivo/Types/District.hs')
-rw-r--r--lib/Malodivo/Types/District.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Malodivo/Types/District.hs b/lib/Malodivo/Types/District.hs
new file mode 100644
index 0000000..a46628d
--- /dev/null
+++ b/lib/Malodivo/Types/District.hs
@@ -0,0 +1,41 @@
+{-|
+Districts can be encoded to and decoded from JSON:
+
+>>> import Data.Aeson (decode, encode)
+>>> import Data.ByteString.Lazy.Char8 (pack)
+
+>>> encode Palolene
+"\"Palolene\""
+
+>>> encode [ Lakos, SouthernPalolene ]
+"[\"Lakos\",\"SouthernPalolene\"]"
+
+>>> decode . pack $ "[ \"Lakos\" ]" :: Maybe [District]
+Just [Lakos]
+-}
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE DeriveGeneric #-}
+
+module Malodivo.Types.District
+ ( District(..)
+ ) where
+
+import GHC.Generics (Generic)
+
+import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
+import Data.Hashable (Hashable)
+
+-- | District of the Kindom of Malodivo.
+data District
+ = Palolene
+ | SouthernPalolene
+ | Lakos
+ deriving ( Eq
+ , Hashable
+ , Show
+ , Generic
+ , FromJSON
+ , FromJSONKey
+ , ToJSON
+ , ToJSONKey
+ )