{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module ROC.ID.Location
( Location (..)
, parseLocation
, printLocation
, randomLocation
) where
import Control.Monad.Random.Class (MonadRandom (..))
import Data.Text (Text)
import GHC.Generics (Generic)
import ROC.ID.Language (Language (..))
import ROC.ID.Utilities
data Location
= A
| B
| C
| D
| E
| F
| G
| H
| I
| J
| K
| L
| M
| N
| O
| P
| Q
| R
| S
| T
| U
| V
| W
| X
| Y
| Z
deriving (Bounded, Enum, Eq, Generic, Ord, Read, Show)
parseLocation :: Char -> Maybe Location
parseLocation c = maybeRead [c]
printLocation :: Language -> Location -> Text
printLocation = \case
English -> printLocationEnglish
Chinese -> printLocationChinese
printLocationChinese :: Location -> Text
printLocationChinese = \case
A -> "臺北市"
B -> "臺中市"
C -> "基隆市"
D -> "臺南市"
E -> "高雄市"
F -> "新北市"
G -> "宜蘭縣"
H -> "桃園市"
I -> "嘉義市"
J -> "新竹縣"
K -> "苗栗縣"
L -> "臺中縣"
M -> "南投縣"
N -> "彰化縣"
O -> "新竹市"
P -> "雲林縣"
Q -> "嘉義縣"
R -> "臺南縣"
S -> "高雄縣"
T -> "屏東縣"
U -> "花蓮縣"
V -> "臺東縣"
W -> "金門縣"
X -> "澎湖縣"
Y -> "陽明山"
Z -> "連江縣"
printLocationEnglish :: Location -> Text
printLocationEnglish = \case
A -> "Taipei City"
B -> "Taichung City"
C -> "Keelung City"
D -> "Tainan City"
E -> "Kaohsiung City"
F -> "New Taipei City"
G -> "Yilan County"
H -> "Taoyuan City"
I -> "Chiayi City"
J -> "Hsinchu County"
K -> "Miaoli County"
L -> "Taichung County"
M -> "Nantou County"
N -> "Changhua County"
O -> "Hsinchu City"
P -> "Yunlin County"
Q -> "Chiayi County"
R -> "Pingtung County"
S -> "Kaohsiung County"
T -> "Pingtung County"
U -> "Hualien County"
V -> "Taitung County"
W -> "Kinmen County"
X -> "Penghu County"
Y -> "Yangmingshan"
Z -> "Lienchiang County"
randomLocation :: MonadRandom m => m Location
randomLocation = randomBoundedEnum