getFunKinds :: Monad m => ClassMap -> Kind -> m (Set.Set Kind)
getFunKinds cm k = case k of
    FunKind {} -> return $ Set.singleton k
    ClassKind c -> case Map.lookup c cm of
         Just info -> do
             ks <- mapM (getFunKinds cm) $ Set.toList $ classKinds info
             return $ keepMinKinds cm ks
         _ -> fail $ "not a function kind '" ++ showId c "'"

-- | compute arity from a raw kind
getFunKinds :: Monad m => ClassMap -> Kind -> m (Set.Set Kind)
getFunKinds cm k = case k of
    FunKind {} -> return $ Set.singleton k
    ClassKind c -> case Map.lookup c cm of
         Just info -> do
             ks <- mapM (getFunKinds cm) $ Set.toList $ classKinds info
             return $ keepMinKinds cm ks
         _ -> fail $ "not a function kind '" ++ showId c "'"

-- | compute arity from a raw kind
getFunKinds cm k = case k of
    FunKind {} -> return $ Set.singleton k
    ClassKind c -> case Map.lookup c cm of
         Just info -> do
             ks <- mapM (getFunKinds cm) $ Set.toList $ classKinds info
             return $ keepMinKinds cm ks
         _ -> fail $ "not a function kind '" ++ showId c "'"

-- | compute arity from a raw kind