Skip to content

Commit 2cda6b9

Browse files
Use nubOrd when possible (#61)
1 parent 139b21f commit 2cda6b9

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

src/Constrained/Core.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,3 @@ instance Typeable c => Show (Evidence c) where
129129
-- | Take the union of two `Maybe` values with a given union operator
130130
unionWithMaybe :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a
131131
unionWithMaybe f ma ma' = (f <$> ma <*> ma') <|> ma <|> ma'
132-

src/Constrained/NumOrd.hs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import Constrained.List
6464
import Constrained.PrettyUtils
6565
import Control.Applicative ((<|>))
6666
import Control.Arrow (first)
67+
import Data.Containers.ListUtils
6768
import Data.Foldable
6869
import Data.Kind
6970
import Data.List (nub)
@@ -362,17 +363,6 @@ conformsToNumSpec i (NumSpecInterval ml mu) = maybe True (<= i) ml && maybe True
362363
-- implementations are found here
363364
-- =====================================================================
364365

365-
-- | Strip out duplicates (in n-log(n) time, by building an intermediate Set)
366-
nubOrd :: Ord a => [a] -> [a]
367-
nubOrd =
368-
loop mempty
369-
where
370-
loop _ [] = []
371-
loop s (a : as)
372-
| a `Set.member` s = loop s as
373-
| otherwise =
374-
let s' = Set.insert a s in s' `seq` a : loop s' as
375-
376366
-- | Builds a MemberSpec, but returns an Error spec if the list is empty
377367
nubOrdMemberSpec :: Ord a => String -> [a] -> Specification a
378368
nubOrdMemberSpec message xs =
@@ -936,7 +926,7 @@ instance Logic IntW where
936926

937927
propagateMemberSpec AddW (HOLE :<: i) es =
938928
memberSpec
939-
(nub $ mapMaybe (safeSubtract i) (NE.toList es))
929+
(nubOrd $ mapMaybe (safeSubtract i) (NE.toList es))
940930
( NE.fromList
941931
[ "propagateSpecFn on (" ++ show i ++ " +. HOLE)"
942932
, "The Spec is a MemberSpec = " ++ show es -- show (MemberSpec @HasSpec @TS es)

0 commit comments

Comments
 (0)