6
6
7
7
module CHR.Utils
8
8
(
9
+ {-
9
10
-- * Set
10
11
unionMapSet
11
12
@@ -18,18 +19,24 @@ module CHR.Utils
18
19
-- * List
19
20
, hdAndTl', hdAndTl
20
21
, maybeNull
21
- , maybeHd
22
+ -}
23
+ maybeHd
24
+ {-
22
25
, wordsBy
23
26
, initlast, initlast2
24
27
, last'
25
28
, firstNotEmpty
26
29
, listSaturate, listSaturateWith
27
30
, spanOnRest
28
31
, filterMb
32
+ -}
29
33
, splitPlaces
30
34
, combineToDistinguishedEltsBy
35
+ {-
31
36
, partitionOnSplit
37
+ -}
32
38
, zipWithN
39
+ {-
33
40
34
41
-- * Tuple
35
42
, tup123to1, tup123to2
@@ -82,19 +89,26 @@ module CHR.Utils
82
89
, showUnprefixed
83
90
84
91
-- * Ordering
92
+ -}
85
93
, orderingLexic
94
+ {-
86
95
, orderingLexicList
87
96
88
97
-- * Misc
98
+ -}
89
99
, panic
90
-
100
+ {-
91
101
, isSortedByOn
92
102
, sortOnLazy
93
103
, sortOn
104
+ -}
94
105
, sortByOn
106
+ {-
95
107
, groupOn
96
108
, groupByOn
109
+ -}
97
110
, groupSortOn
111
+ {-
98
112
, groupSortByOn
99
113
, nubOn
100
114
@@ -115,6 +129,7 @@ module CHR.Utils
115
129
-- * Monad
116
130
, firstMaybeM
117
131
, breakM
132
+ -}
118
133
)
119
134
where
120
135
@@ -128,6 +143,8 @@ import qualified Data.Set as Set
128
143
import qualified Data.Map as Map
129
144
-- import qualified Data.Graph as Graph
130
145
146
+ {-
147
+
131
148
-------------------------------------------------------------------------
132
149
-- Set
133
150
-------------------------------------------------------------------------
@@ -147,11 +164,13 @@ inverseMap mk = Map.fromList . map (uncurry mk) . Map.toList
147
164
-- | Show keys of map using a separator
148
165
showStringMapKeys :: Map.Map String x -> String -> String
149
166
showStringMapKeys m sep = concat $ intersperse sep $ Map.keys m
167
+ -}
150
168
151
169
-------------------------------------------------------------------------
152
170
-- List
153
171
-------------------------------------------------------------------------
154
172
173
+ {-
155
174
-- | Get head and tail, with default if empty list
156
175
hdAndTl' :: a -> [a] -> (a,[a])
157
176
hdAndTl' _ (a:as) = (a,as)
@@ -161,6 +180,7 @@ hdAndTl' n [] = (n,[])
161
180
hdAndTl :: [a] -> (a,[a])
162
181
hdAndTl = hdAndTl' (panic "hdAndTl")
163
182
{- # INLINE hdAndTl #-}
183
+ -}
164
184
165
185
maybeNull :: r -> ([a ] -> r ) -> [a ] -> r
166
186
maybeNull n f l = if null l then n else f l
@@ -170,6 +190,7 @@ maybeHd :: r -> (a -> r) -> [a] -> r
170
190
maybeHd n f = maybeNull n (f . head )
171
191
{-# INLINE maybeHd #-}
172
192
193
+ {-
173
194
-- | Split up in words by predicate
174
195
wordsBy :: (a -> Bool) -> [a] -> [[a]]
175
196
wordsBy p l
@@ -236,6 +257,8 @@ filterMb :: (a -> Maybe b) -> [a] -> [b]
236
257
filterMb p = catMaybes . map p
237
258
{- # INLINE filterMb #-}
238
259
260
+ -}
261
+
239
262
-- | Split at index places (inspired by/from split package). Places should be increasing, starting with an index >= 0.
240
263
-- The number of sublists returned is one higher than the number of places.
241
264
--
@@ -279,6 +302,8 @@ zipWithN :: ([x] -> y) -> [[x]] -> [y]
279
302
zipWithN f l | any null l = []
280
303
| otherwise = f (map head l) : zipWithN f (map tail l)
281
304
305
+ {-
306
+
282
307
-------------------------------------------------------------------------
283
308
-- Tupling, untupling
284
309
-------------------------------------------------------------------------
@@ -353,6 +378,7 @@ fth = fth4
353
378
{- # INLINE fth4 #-}
354
379
{- # INLINE fth #-}
355
380
381
+
356
382
-------------------------------------------------------------------------
357
383
-- String
358
384
-------------------------------------------------------------------------
@@ -434,6 +460,9 @@ splitForQualified s
434
460
(nq,(_:ns)) -> nq ++ [concatMap ("."++) ns]
435
461
_ -> ws'
436
462
463
+ -}
464
+
465
+
437
466
-------------------------------------------------------------------------
438
467
-- Misc
439
468
-------------------------------------------------------------------------
@@ -445,6 +474,8 @@ panic m = error ("panic: " ++ m)
445
474
-- group/sort/nub combi's
446
475
-------------------------------------------------------------------------
447
476
477
+ {-
478
+
448
479
isSortedByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Bool
449
480
isSortedByOn cmp sel l
450
481
= isSrt l
@@ -457,6 +488,8 @@ sortOnLazy :: Ord b => (a -> b) -> [a] -> [a]
457
488
sortOnLazy = sortByOn compare
458
489
{- # INLINE sortOnLazy #-}
459
490
491
+ -}
492
+
460
493
#if __GLASGOW_HASKELL__ >= 710
461
494
#else
462
495
-- | The original Data.List.sortOn.
@@ -466,6 +499,7 @@ sortOn = sortOnLazy
466
499
{-# INLINE sortOn #-}
467
500
#endif
468
501
502
+
469
503
sortByOn :: (b -> b -> Ordering ) -> (a -> b ) -> [a ] -> [a ]
470
504
sortByOn cmp sel = sortBy (cmp `on` sel) -- (\e1 e2 -> sel e1 `cmp` sel e2)
471
505
@@ -475,6 +509,7 @@ groupOn sel = groupBy ((==) `on` sel) -- (\e1 e2 -> sel e1 == sel e2)
475
509
groupSortOn :: Ord b => (a -> b ) -> [a ] -> [[a ]]
476
510
groupSortOn sel = groupOn sel . sortOn sel
477
511
512
+ {-
478
513
groupByOn :: (b -> b -> Bool) -> (a -> b) -> [a] -> [[a]]
479
514
groupByOn eq sel = groupBy (eq `on` sel) -- (\e1 e2 -> sel e1 `eq` sel e2)
480
515
@@ -499,6 +534,7 @@ partitionOnSplit split adapt pred xs = foldr sel ([],[]) xs
499
534
where sel x ~(ts,fs) | pred x' = ((adapt x',y):ts, fs)
500
535
| otherwise = ( ts, y:fs)
501
536
where (x',y) = split x
537
+ -}
502
538
503
539
{-
504
540
partition :: (a -> Bool) -> [a] -> ([a],[a])
@@ -510,6 +546,7 @@ select p x ~(ts,fs) | p x = (x:ts,fs)
510
546
| otherwise = (ts, x:fs)
511
547
-}
512
548
549
+ {-
513
550
-------------------------------------------------------------------------
514
551
-- Partitioning with rebuild
515
552
-------------------------------------------------------------------------
@@ -522,6 +559,8 @@ partitionAndRebuild f (v:vs)
522
559
where (vs1,vs2,mk) = partitionAndRebuild f vs
523
560
partitionAndRebuild _ [] = ([], [], \_ _ -> [])
524
561
562
+ -}
563
+
525
564
-------------------------------------------------------------------------
526
565
-- Ordering
527
566
-------------------------------------------------------------------------
@@ -536,10 +575,13 @@ orderingLexic :: Ordering -> Ordering -> Ordering
536
575
orderingLexic o1 o2 = if o1 == EQ then o2 else o1
537
576
{-# INLINE orderingLexic #-}
538
577
578
+ {-
579
+
539
580
-------------------------------------------------------------------------
540
581
-- Maybe
541
582
-------------------------------------------------------------------------
542
583
584
+
543
585
panicJust :: String -> Maybe a -> a
544
586
panicJust m = maybe (panic m) id
545
587
{- # INLINE panicJust #-}
@@ -569,6 +611,8 @@ maybeOr n fa fb ma mb
569
611
Just b -> fb b
570
612
_ -> n
571
613
614
+ -}
615
+
572
616
-------------------------------------------------------------------------
573
617
-- Strongly Connected Components
574
618
-------------------------------------------------------------------------
@@ -578,6 +622,7 @@ scc :: Ord n => [(n,[n])] -> [[n]]
578
622
scc = map Graph.flattenSCC . Graph.stronglyConnComp . map (\(n,ns) -> (n, n, ns))
579
623
-}
580
624
625
+ {-
581
626
-------------------------------------------------------------------------
582
627
-- Map
583
628
-------------------------------------------------------------------------
@@ -609,3 +654,7 @@ breakM :: Monad m => (a -> Bool) -> [m a] -> m ([a], Maybe (a,[m a]))
609
654
breakM p l = br [] l >>= \(acc,res) -> return (reverse acc, res)
610
655
where br acc [] = return (acc, Nothing)
611
656
br acc (m:ms) = m >>= \x -> if p x then return (acc, Just (x, ms)) else br (x:acc) ms
657
+
658
+ -}
659
+
660
+
0 commit comments