{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedLists #-}

module Storage where

import           Data.Array (Array, array)
import qualified Data.Array as A
import           Data.Serialize (Serialize)
import           Data.Word (Word8, Word32)
import           GHC.Generics (Generic)
import           Database.Tansu
import           Database.Tansu.Backend.SQLite3

data Character = Character
  { charDescr :: String
  , charLang  :: String
  } deriving (Eq, Show, Generic, Serialize)

newtype Pane = Pane
  { fromPane :: Array Word8 PaneInfo }
    deriving (Eq, Show, Generic, Serialize)

data PaneInfo = PaneInfo
  { paneLang :: Maybe String
  } deriving (Eq, Show, Generic, Serialize)

data Key = SubpaneIx Word8 | CodePointIx Word32
  deriving (Eq, Show, Generic, Serialize)

getPanes :: IO Pane
getPanes = return $ Pane $ array (minBound, maxBound)
  [ (i, PaneInfo (if i == 0
                    then Just "trinako"
                    else if i == 1
                           then Just "verdash"
                           else Nothing))
  | i <- [minBound..maxBound]
  ]
