I've just started working on my third school assignment and i've run into yet another noob error i can't seem to solve on my own.
We're to write a Sudoku solver, and i'm currently writing a function which will determine wether the elements in my Sudoku are of the right type. They're of the type Maybe Int (Just Int or Nothing).
Here are the relevant sections of code:
data Sudoku = Sudoku [[Maybe Int]]
deriving (Eq, Show)
validValue :: Maybe Int -> Bool
validValue Nothing = True
validValue (Just n) = True
checkEveryElement :: Sudoku -> Bool
checkEveryElement (Sudoku (x:xs))
| and $ map $ validValue $ concat (x:xs) == True
The Sudoku itself is represented by a list of 9 elements, where each element is a list which consists of 9 elements themselves. So x in the above list (the head of the total list) is actually a list of 9 elements.
I've only started learning how to program these past five weeks, so bear with me. :) I am not sure i have used and correctly. The error i get while compiling is at the last line of the above sections of code.
Thanks!
edit: I forgot the actual error...'Possibly incorrect indentation or mismatched brackets.'
== True
: the 'and' will already evaluate to aBool
, so there is no need to test equality withTrue
. One solution is to change the==
to=
, but if you want to be painfully explicit about the guard, you could write== True = True
. – crockeeavalidValue
currently can't returnFalse
. I think you probably meantvalidValue (Just n) = {- some expression I could guess but you can figure out evaluating to True if n is valid and to False otherwise -}
– dfeuer