What does this error message mean

Short intro (skip down for the real reason for this email) : Hi, I'm a student at Chalmers and have finished the Haskell course but actually (is IS weird, but I'm pretty sure I like it... :) ) found the language to be pretty cool and decided to try and make an ascii-based Dungeon Master type game. For anyone who doesn't know what that is : Its a game in which you walk in a dungeon with corridors in a firstperson view. These are pictures that show what it looks like when you are looking down a corridor that turns right two and respectively one "moves" ahead of the current position. (Yes, I plan to make these better looking :) ) corrl_2 = ["##############", "# \\ / #", "# \\ ____ / #", "# | } #", "# |____} #", "# / \\ #", "# / \\ #", "##############"] corrl_1 = ["##############", "# \\ / #", "# \\ ______| #", "# | | #", "# |______| #", "# / | #", "# / \\ #", "##############"] This is the whole program. draw simply prints out all three pictures (including the overhead map found below) My (current) problem lies in whatPic, which returns the error Program error: {whatPic Facing2_North (1,6)} if I type in whatPic North (1,6) or just call it through the draw2 function (which is supposed to be the main drawing function, and it actually works.. Well it did yesterday until I did something :D (sorry about pine wrapping the lines.. if you're in luck you wont notice it.) import Observe draw = putStr ((unlines corrl_2) ++ (unlines corrl_1) ++ (unlines maplevel1)) data Facing2 = North | South draw2 = putStr (unlines (whatPic North (findPos 'P' 1))) findPos :: Char -> Int -> (Int,Int) findPos obj location | head (drop (location) (unlines maplevel1)) == obj = (location `div` 14,location `mod` 15) | otherwise = findPos obj (location + 1) whatPic :: Facing2 -> (Int,Int) -> Pic whatPic facin (x,y) | corridorType facin (x,y) == (2, "rTurn1") = corrl_1 | corridorType facin (x,y) == (2, "rTurn2") = corrl_2 corridorType :: Facing2 -> (Int,Int) -> (Int, String) corridorType facing (x,y) | observe "distWall" distWall facing (x,y) (x,y) == 4 && (whatIs (findPos 'P' 1) (1,-2) == ' ') = (2, "rTurn") | otherwise = (2, "rTurn") distWall :: Facing2 -> (Int,Int) -> (Int,Int) -> Int distWall North (x,y) (newx,newy) | whatIs (x,y) (x,y-1) == '#' = abs (y - newy) | whatIs (x,y) (x,y-1) == ' ' = distWall North (x,y) (x,y-1) --distWall (North) (x,y) (newx,newy) = 2 --distWall (South) (x,y) (newx,newy) = 2 whatIs :: (Int,Int) -> (Int,Int) -> Char whatIs (x,y) (xdiff,ydiff) = head (drop (x + xdiff + y + ydiff ) (unlines maplevel1)) --[1,2,3,4,5] type Pic = [[Char]] maplevel1 = ["##############", "# #", "### #", "# #", "# # #", "# # #", "#P#m #", "##############"] corrl_2 :: Pic corrl_2 = ["##############", "# \\ / #", "# \\ ____ / #", "# | } #", "# |____} #", "# / \\ #", "# / \\ #", "##############"] corrl_1 = ["##############", "# \\ / #", "# \\ ______| #", "# | | #", "# |______| #", "# / | #", "# / \\ #", "##############"] I'm sure its something simple.. I just can't make out what could be wrong right now. Thanks for any replies :) ------------------------------------------------------------------------- Anders Elfgren || AKA: Srekel and Farfar Homepage: http://hem.passagen.se/srekel || Alt email: srekel@icqmail.com ICQ: 4596105 || AIM: Srekel - Kaka e gott || - Cs e halva mitt liv -------------------------------------------------------------------------

At 9:38pm on Oct 30, 2001, haskell-cafe-admin@haskell.org wrote:
My (current) problem lies in whatPic, which returns the error Program error: {whatPic Facing2_North (1,6)} if I type in whatPic North (1,6) or just call it through the draw2 function (which is supposed to be the main drawing function, and it actually works.. Well it did yesterday until I did something :D
The problem is in whatPic. Messages like Program error: {whatPic Facing2_North (1,6)} say that there is no matching function RHS for the arguments specified. In your case the arguments did match the patterns specified in whatPic, but neither of the two function guards was true. Try this to check: whatPic :: Facing2 -> (Int,Int) -> Pic whatPic facin (x,y) | corridorType facin (x,y) == (2, "rTurn1") = corrl_1 | corridorType facin (x,y) == (2, "rTurn2") = corrl_2 | otherwise = error "whatPic: cases exhausted" -- Richard
participants (2)
-
Anders Elfgren
-
Richard Watson