gdritter repos bytor / master src / Bytor / Types.hs
master

Tree @master (Download .tar.gz)

Types.hs @master

103e3fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{-# LANGUAGE TemplateHaskell #-}

module Bytor.Types where

import           Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import           Data.Sequence (Seq)
import qualified Data.Sequence as Seq
import           Data.ByteString (ByteString)
import           Data.Text (Text)
import           Data.Time.Clock (UTCTime)
import           Lens.Micro.Platform (makeLenses)
import           Network.Courriel.Types

data Modifier
  = None
  | Ctrl
  | Meta
    deriving (Eq, Show, Read, Ord)

data KeyCode = KeyCode
  { _kcChar :: Char
  , _kcMod  :: Modifier
  } deriving (Eq, Show, Read, Ord)

makeLenses ''KeyCode

data Action
  = Quit
    deriving (Eq, Show, Read)

data Config = Config
  { _confKeymap :: Map KeyCode Action
  } deriving (Eq, Show, Read)

defaultKeymap :: Map KeyCode Action
defaultKeymap = Map.fromList
  [ (KeyCode 'q' Ctrl, Quit)
  ]

makeLenses ''Config

newtype Mbox = Mbox { _mbEmails :: Seq Email }
  deriving (Eq, Show, Read)

makeLenses ''Mailbox

data State = State
  { _stConfiguration :: Config
  , _stMailboxes     :: Mbox
  , _stMessage       :: Text
  } deriving (Eq, Show, Read)

emptyState :: State
emptyState = State
  { _stConfiguration = Config defaultKeymap
  , _stMailboxes     = Mbox Seq.empty
  , _stMessage       = "Hello"
  }

makeLenses ''State

data Cursor = Cursor
  deriving (Eq, Show, Ord)

data Event = Event
  deriving (Eq, Show, Ord)