get str (S((a,b):xs)) = if str == a then Just b
else get str xs
xs
is a list of type [(String, a)]
, but the second argument of get
must be a Subst a
. It would work if you used a constructor to construct a value of the correct type,
get str (S((a,b):xs)) = if str == a then Just b
else get str (S xs)
but it is simpler to use the list directly to look up the variable,
Prelude> :t lookup
lookup :: Eq a => a -> [(a, b)] -> Maybe b
so
get str (S xs) = lookup str xs
does exactly what you want.