justCoeffectTypesConverted :: (?globals::Globals)
  => Span -> [(a, (Kind, b))] -> Checker [(a, (Type, b))]
justCoeffectTypesConverted s xs = mapM convert xs >>= (return . catMaybes)
  where
    convert (var, (KPromote t, q)) = do
      k <- inferKindOfType s t
      if isCoeffectKind k
        then return $ Just (var, (t, q))
        else return Nothing
    convert (var, (KVar v, q)) = do
      k <- inferKindOfType s (TyVar v)
      if isCoeffectKind k
        then return $ Just (var, (TyVar v, q))
        else return Nothing
    convert _ = return Nothing
justCoeffectTypesConverted :: (?globals::Globals)
  => Span -> [(a, (Kind, b))] -> Checker [(a, (Type, b))]
justCoeffectTypesConverted s xs = mapM convert xs >>= (return . catMaybes)
  where
    convert (var, (KPromote t, q)) = do
      k <- inferKindOfType s t
      if isCoeffectKind k
        then return $ Just (var, (t, q))
        else return Nothing
    convert (var, (KVar v, q)) = do
      k <- inferKindOfType s (TyVar v)
      if isCoeffectKind k
        then return $ Just (var, (TyVar v, q))
        else return Nothing
    convert _ = return Nothing
justCoeffectTypesConverted s xs = mapM convert xs >>= (return . catMaybes)
  where
    convert (var, (KPromote t, q)) = do
      k <- inferKindOfType s t
      if isCoeffectKind k
        then return $ Just (var, (t, q))
        else return Nothing
    convert (var, (KVar v, q)) = do
      k <- inferKindOfType s (TyVar v)
      if isCoeffectKind k
        then return $ Just (var, (TyVar v, q))
        else return Nothing
    convert _ = return Nothing