From 5dc3696f38433c79939bb182c4590a6ce04f4c63 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 19 Dec 2024 22:40:41 +0530 Subject: Test mock setup for update + 1 spec for update case --- src/Chelleport.hs | 4 ++-- src/Chelleport/Types.hs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Chelleport.hs b/src/Chelleport.hs index 2a95a9a..6b443b5 100644 --- a/src/Chelleport.hs +++ b/src/Chelleport.hs @@ -11,7 +11,7 @@ import Chelleport.Types import Chelleport.Utils (intToCInt) import qualified Chelleport.View import Control.Monad.IO.Class (MonadIO) -import Control.Monad.Reader (MonadReader, ReaderT (runReaderT)) +import Control.Monad.Reader (ReaderT (runReaderT)) import Data.List ((\\)) import Data.Maybe (fromMaybe, isJust) import qualified SDL @@ -66,7 +66,7 @@ eventToAction _state event = _ -> Nothing update :: - (MonadIO m, MonadAppShell m, MonadDraw m, MonadControl m, MonadReader DrawContext m) => + (MonadAppShell m, MonadDraw m, MonadControl m) => State -> AppAction -> m (State, Maybe AppAction) diff --git a/src/Chelleport/Types.hs b/src/Chelleport/Types.hs index c1cf386..a6aa7cc 100644 --- a/src/Chelleport/Types.hs +++ b/src/Chelleport/Types.hs @@ -1,12 +1,15 @@ module Chelleport.Types where import Control.Monad.Reader (MonadIO, MonadReader, ReaderT) +import Data.Word (Word8) import qualified Graphics.X11 as X11 import qualified SDL import qualified SDL.Font as TTF type Cell = [Char] +type Color = SDL.V4 Word8 + type KeySequence = [Char] type KeyGrid = [[Cell]] @@ -17,6 +20,7 @@ data State = State stateIsMatched :: Bool, stateIsShiftPressed :: Bool } + deriving (Show, Eq) data AppAction = HandleKeyInput SDL.Keycode @@ -26,6 +30,7 @@ data AppAction | IncrementMouseCursor (Int, Int) | ShutdownApp | UpdateShiftState Bool + deriving (Show, Eq) data DrawContext = DrawContext { ctxWindow :: SDL.Window, @@ -43,6 +48,7 @@ type View state = state -> IO () type Initializer state = IO state data MouseButtonType = LeftClick + deriving (Show, Eq) newtype AppM m a = AppM {runAppM :: ReaderT DrawContext m a} deriving (Functor, Applicative, Monad, MonadIO, MonadReader DrawContext) -- cgit v1.3.1