project skeleton
This commit is contained in:
parent
55aaed7550
commit
2b64fe2a0b
4 changed files with 54 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
module Main (main) where
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Haskell!"
|
||||
main = putStrLn "hi"
|
||||
|
|
|
|||
25
src/Game.hs
Normal file
25
src/Game.hs
Normal 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
19
src/Types.hs
Normal 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
9
test/Spec.hs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
module Main where
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = undefined
|
||||
|
||||
main :: IO ()
|
||||
main = hspec spec
|
||||
Loading…
Add table
Add a link
Reference in a new issue