diff --git a/src/Constrained/Core.hs b/src/Constrained/Core.hs index 034e174..e4f8497 100644 --- a/src/Constrained/Core.hs +++ b/src/Constrained/Core.hs @@ -129,4 +129,3 @@ instance Typeable c => Show (Evidence c) where -- | Take the union of two `Maybe` values with a given union operator unionWithMaybe :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a unionWithMaybe f ma ma' = (f <$> ma <*> ma') <|> ma <|> ma' - diff --git a/src/Constrained/NumOrd.hs b/src/Constrained/NumOrd.hs index 7ae77ea..8314392 100644 --- a/src/Constrained/NumOrd.hs +++ b/src/Constrained/NumOrd.hs @@ -64,6 +64,7 @@ import Constrained.List import Constrained.PrettyUtils import Control.Applicative ((<|>)) import Control.Arrow (first) +import Data.Containers.ListUtils import Data.Foldable import Data.Kind import Data.List (nub) @@ -362,17 +363,6 @@ conformsToNumSpec i (NumSpecInterval ml mu) = maybe True (<= i) ml && maybe True -- implementations are found here -- ===================================================================== --- | Strip out duplicates (in n-log(n) time, by building an intermediate Set) -nubOrd :: Ord a => [a] -> [a] -nubOrd = - loop mempty - where - loop _ [] = [] - loop s (a : as) - | a `Set.member` s = loop s as - | otherwise = - let s' = Set.insert a s in s' `seq` a : loop s' as - -- | Builds a MemberSpec, but returns an Error spec if the list is empty nubOrdMemberSpec :: Ord a => String -> [a] -> Specification a nubOrdMemberSpec message xs = @@ -936,7 +926,7 @@ instance Logic IntW where propagateMemberSpec AddW (HOLE :<: i) es = memberSpec - (nub $ mapMaybe (safeSubtract i) (NE.toList es)) + (nubOrd $ mapMaybe (safeSubtract i) (NE.toList es)) ( NE.fromList [ "propagateSpecFn on (" ++ show i ++ " +. HOLE)" , "The Spec is a MemberSpec = " ++ show es -- show (MemberSpec @HasSpec @TS es)