From 2b64fe2a0ba57004bcab603c9dee9fae7553d8b4 Mon Sep 17 00:00:00 2001 From: Sidharth Kulkarni Date: Sat, 2 May 2026 11:38:52 -0700 Subject: [PATCH] project skeleton --- app/Main.hs | 2 +- src/Game.hs | 25 +++++++++++++++++++++++++ src/Types.hs | 19 +++++++++++++++++++ test/Spec.hs | 9 +++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Game.hs create mode 100644 src/Types.hs create mode 100644 test/Spec.hs diff --git a/app/Main.hs b/app/Main.hs index f16f6f5..1dc21a2 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,4 +1,4 @@ module Main (main) where main :: IO () -main = putStrLn "Hello, Haskell!" +main = putStrLn "hi" diff --git a/src/Game.hs b/src/Game.hs new file mode 100644 index 0000000..441a2e4 --- /dev/null +++ b/src/Game.hs @@ -0,0 +1,25 @@ +module Game where + +import Data.Text +import Types + +newtype PlayerName = MkPlayerName Text + deriving (Eq, Show, Ord) + +data PlayerState = MkPlayerState + { name :: Text + , score :: Int + } + deriving (Eq, Show) + +data GameState = MkGameState + { board :: GameBoard + , players :: PlayerState + } + deriving (Eq, Show) + +newRandomBoard :: Int -> Int -> IO GameBoard +newRandomBoard width height = undefined + +newGame :: [PlayerName] -> IO GameState +newGame = undefined diff --git a/src/Types.hs b/src/Types.hs new file mode 100644 index 0000000..cd2871d --- /dev/null +++ b/src/Types.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE NamedFieldPuns #-} + +module Types where + +import Data.Array +import Data.Array.Base (genArray) + +data GameBoard = MkGameBoard + { width :: Int + , height :: Int + , board :: Array (Int, Int) (Maybe Int) + } + deriving (Show, Eq) + +mkEmptyBoard :: Int -> Int -> GameBoard +mkEmptyBoard width height = MkGameBoard{width, height, board} + where + board :: Array (Int, Int) (Maybe Int) + board = genArray ((0, 0), (width - 1, height - 1)) (const Nothing) diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..514babd --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,9 @@ +module Main where + +import Test.Hspec + +spec :: Spec +spec = undefined + +main :: IO () +main = hspec spec