You need to add parentheses around your cons expressions in two places:
connected :: [(Integer,Integer)] -> Bool
connected [] = True
connected [(_,_)] = True
connected ((a,b):(c,d):xs) -- (2)
| a > c = False
| otherwise = connected ((c,d):xs) -- (1)
Function application binds more tightly than infix operators, so connected (c,d) : xs
gets parsed as (connected (c,d)) : xs
.
A similar thing happens in the pattern expression. Although the unhelpful error message you get there is rather unfortunate.
Opinionated side note: I recommend always writing infix operators with spaces around them (for example, a : b
instead of a:b
), because I think omitting the whitespace subtly implies that the operator binds more tightly than it really does.