Skip to content

Commit

Permalink
Use cartesianProduct instead of setProduct where possible (#112)
Browse files Browse the repository at this point in the history
* remove setProduct, use cartesianProduct (fixes #111)

* conditional setProduct via CPP (fixes #111)
  • Loading branch information
subttle authored and snowleopard committed Oct 6, 2018
1 parent 42fc617 commit 175234b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Algebra/Graph/Relation/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Algebra.Graph.Relation.Internal
Expand Down Expand Up @@ -171,7 +172,11 @@ instance NFData a => NFData (Relation a) where

-- | Compute the Cartesian product of two sets. /Note: this function is for internal use only/.
setProduct :: Set a -> Set b -> Set (a, b)
#if MIN_VERSION_containers(0,5,11)
setProduct = Set.cartesianProduct
#else
setProduct x y = Set.fromDistinctAscList [ (a, b) | a <- Set.toAscList x, b <- Set.toAscList y ]
#endif

instance (Ord a, Num a) => Num (Relation a) where
fromInteger = vertex . fromInteger
Expand Down

0 comments on commit 175234b

Please sign in to comment.