project skeleton

This commit is contained in:
Sidharth Kulkarni 2026-05-02 11:38:52 -07:00
parent 55aaed7550
commit 2b64fe2a0b
Signed by: skulk
SSH key fingerprint: SHA256:Jby+S9d1WmwqnXIrngHgccYNHz+cYquxN1zm3ym3Kbg
4 changed files with 54 additions and 1 deletions

View file

@ -1,4 +1,4 @@
module Main (main) where
main :: IO ()
main = putStrLn "Hello, Haskell!"
main = putStrLn "hi"

25
src/Game.hs Normal file
View file

@ -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

19
src/Types.hs Normal file
View file

@ -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)

9
test/Spec.hs Normal file
View file

@ -0,0 +1,9 @@
module Main where
import Test.Hspec
spec :: Spec
spec = undefined
main :: IO ()
main = hspec spec