-- coercion using the language name
primCoerce :: (Typeable a, Typeable b, Language lid1, Language lid2,
               Monad m) => lid1 -> lid2 -> String -> a -> m b
primCoerce i1 i2 err a =
  if language_name i1 == language_name i2
     then return $ fromDyn (toDyn a) $ error "primCoerce"
     else fail $ (if null err then "" else err ++ ": ") ++ "Logic "
              ++ language_name i2 ++ " expected, but "
              ++ language_name i1 ++ " found"
primCoerce :: (Typeable a, Typeable b, Language lid1, Language lid2,
               Monad m) => lid1 -> lid2 -> String -> a -> m b
primCoerce i1 i2 err a =
  if language_name i1 == language_name i2
     then return $ fromDyn (toDyn a) $ error "primCoerce"
     else fail $ (if null err then "" else err ++ ": ") ++ "Logic "
              ++ language_name i2 ++ " expected, but "
              ++ language_name i1 ++ " found"
primCoerce i1 i2 err a =
  if language_name i1 == language_name i2
     then return $ fromDyn (toDyn a) $ error "primCoerce"
     else fail $ (if null err then "" else err ++ ": ") ++ "Logic "
              ++ language_name i2 ++ " expected, but "
              ++ language_name i1 ++ " found"