ryDivisorsToInvariantFactors :: [(Integer, Integer)] -> [Integer]
elementaryDivisorsToInvariantFactors = reverse .
                                       fmap (product . fmap (\(prime, power) -> prime^power)) .
                                       transpose .
                                       fmap reverse .
                                       groupBy ((==) `on` fst)

elementaryDivisorsToInvariantFactors :: [(Integer, Integer)] -> [Integer]
elementaryDivisorsToInvariantFactors = reverse .
                                       fmap (product . fmap (\(prime, power) -> prime^power)) .
                                       transpose .
                                       fmap reverse .
                                       groupBy ((==) `on` fst)
elementaryDivisorsToInvariantFactors = reverse .
                                       fmap (product . fmap (\(prime, power) -> prime^power)) .
                                       transpose .
                                       fmap reverse .
                                       groupBy ((==) `on` fst)