John
John

Reputation: 41

Haskell: parse error in pattern 3

data Peg = Red | Green | Blue | Yellow | Orange | Purple
    deriving (Show, Eq, Ord)

type Code = [Peg]

data Move = Move Code Int Int
      deriving (Show, Eq)

isConsistent :: Move -> Code -> Bool
isConsistent (move1 code1 num1 num2) code2 = True --parse error here

Relatively new to Haskell. Wondering why I receive the following error message after attempting to load this.

Parse error in pattern: move1

Upvotes: 3

Views: 337

Answers (1)

genisage
genisage

Reputation: 1169

move1 isn't a data constructor (which is what you're allowed to pattern match on) and in fact it can't be since they have to start with uppercase letters. Replace it with the constructor Move from your data declaration and the error should go away.

You will probably still get some warnings like "code1 defined but not used" you can get rid of them by changing the pattern to (Move _ _ _) if you really don't care about the contents.

Upvotes: 8

Related Questions