I’m writing a Haskell function that takes 2 substitutions as arguments. I’ve handled the case where if either of the arguments is Nothing, then the function will return Nothing. If neither one is Nothing, it should combine them into a single substitution. I’ve done the following:
args :: Maybe (Subst a) -> Maybe (Subst a) -> Maybe (Subst a)
args (Just v) (Just v') = Just (v ++ v')
args _ _ = Nothing
However, I’m receiving errors that the expected type doesn’t match the actual type. I’m confused as to why. Any ideas?
The type of
++isbut you’re trying to apply it to two values of type
Subst a.You could write a helper function
combineSubslike this:You can also pattern match on
Sin the arguments of your functionargs.