elem (c,_)
is not a valid haskell expression, because _
can only be used in a pattern (and not in a value). You almost have the solution with head [snd n | n <- m, fst n == c]
. You should first evaluate it, and check what is inside. It will be simpler and safer.
I would use something like
getVal :: Char -> Mem -> Int
getVal c m = case [snd n | n <- m, fst n == c] of
[] -> 0
x:_ -> x