I am new in Haskell and I had started a little project.
When I want to compile it, I always recieve the error:
[1 of 1] Compiling Main ( src/main.hs, src/main.o )
src/main.hs:51:9:
The type signature for ‘theDungeon’ lacks an accompanying binding
Now I don't know what this error means or how I can fix it.
Here is the source-code:
import Prelude
import qualified UI.HSCurses.Curses
{-- DEFINE THE TYPES --}
data Tile = Tile -- the tiles of the map
{char :: Char
,isBlocking :: Bool
,position :: (Int,Int)}
data Dungeon = Dungeon [Tile] -- the dungeon
data Player = Player -- the player
{namePlayer :: [Char]
,charPlayer :: Char
,positionPlayer :: (Int, Int)
,lvlPlayer :: Int
,epPlayer :: Int
,hpPlayer :: (Int, Int)
,mpPlayer :: (Int, Int)
,damagePlayer :: Int -- how many damage it does
,defensePlayer :: Int -- how many defense it has
,inventoryPLayer :: [Item]
,isAlivePlayer :: Bool} -- it's true if the player isn't dead
data Monster = Monster -- the monster
{nameMonster :: [Char]
,charMonster :: Char
,positionMonster :: (Int, Int)
,hpMonster :: Int
,giveEpMonster :: Int -- how much ep the player becomes if it kills the monster
,damageMonster :: Int
,defenseMonster :: Int
,isAliveMonster :: Bool}
data Type = Potion | BigWeapon | SmallWeapon | Scroll | Armor | Amulet
data Item = Item
{nameItem :: [Char]
,itemType :: Type
,positionItem :: (Int, Int)
,equipableItem :: Bool}
{-- THE MAIN FUNCTION --}
main :: IO ()
main = do
let theDungeon :: Dungeon
theDungeon <- mkDungeon 0 0 []
writeFile "./test.log" $ show theDungeon
{-- DEFINE THE SIZE OF THE MAP --}
screenX = 80
screenY = 24
mapX = screenX
mapY = screenY - 4
{-- THE FUNCTIONS FOR THE DUNGEON --}
mkDungeon :: Int -> Int -> Dungeon -> Dungeon -- function for generating the dungeon
mkDungeon x y dungeon =
if x > mapX -- looks if the line isn't too long
then mkDungeon 0 (y + 1) -- it's too long, so make the next line
else if y == 0 -- if it at the top
then do
dungeon : Tile '#' True (x,y)
mkDungeon (x + 1) y -- make the line full with walls
else if y > 0 && y < mapY -- looks if the line is in the middle
then if x == 0 || x == mapX -- is it at the right or at the left
then do
dungeon : Tile '#' True (x,y)
mkDungeon (x + 1) y -- make the tile to a wall
else do
dungeon : Tile '.' False (x,y)
mkDungeon (x + 1) y -- make it to a floor
else if y == mapX -- looks if it is at the bottom
then do
dungeon : Tile '#' True (x,y)
mkDungeon (x + 1) y
else retu $ dungeon :: Dungeon -- if none of it, the map is finished, retu dungeon
If you (or better 'when') find issues, tell me :D.
