on master help sign in
Removed redundant type families
commit88f93c793c99e18f1bff51cd03e96839e8ffc61b authorArmando Santos <armandoifsantos@gmail.com> dateMon 11 May 2020, 12:34 (6 years ago) parent9a79218
3 files changed+35−33
src/LAoP/Matrix/Internal.hs+11−12 src/LAoP/Matrix/Type.hs+7−7 src/LAoP/Relation/Internal.hs+17−14
src/LAoP/Matrix/Internal.hs+11−12
@@ -369,16 +369,15 @@ matrixBuilder' f =
369369matrixBuilder ::
370370 forall e a b.
371371 ( FLN a b,
372− CountableN b,
373372 Enum a,
374373 Enum b,
375374 Bounded a,
376375 Bounded b,
377376 Eq a,
378− CountableDimsN a b
377+ Countable b
379378 ) => ((a, b) -> e) -> Matrix e (Normalize a) (Normalize b)
380379matrixBuilder f =
381− let r = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
380+ let r = fromInteger $ natVal (Proxy :: Proxy (Count b))
382381 positions = [(a, b) | a <- [minBound .. maxBound], b <- [minBound .. maxBound]]
383382 in fromLists . map (map f) . transpose . buildList r $ positions
384383 where
@@ -429,7 +428,7 @@ fromF' f =
429428fromF ::
430429 forall a b e.
431430 ( Liftable e a b,
432− CountableDimsN a b,
431+ CountableDims a b,
433432 FLN b a
434433 ) =>
435434 (a -> b) ->
@@ -439,8 +438,8 @@ fromF f =
439438 maxA = maxBound @a
440439 minB = minBound @b
441440 maxB = maxBound @b
442− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
443− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
441+ ccols = fromInteger $ natVal (Proxy :: Proxy (Count a))
442+ rrows = fromInteger $ natVal (Proxy :: Proxy (Count b))
444443 elementsA = take ccols [minA .. maxA]
445444 elementsB = take rrows [minB .. maxB]
446445 combinations = (,) <$> elementsA <*> elementsB
@@ -971,7 +970,7 @@ fromFRel' f =
971970fromFRel ::
972971 forall a b.
973972 ( Liftable Boolean a b,
974− CountableDimsN a b,
973+ CountableDims a b,
975974 FL (Normalize b) (Normalize a)
976975 ) =>
977976 (a -> b) ->
@@ -981,8 +980,8 @@ fromFRel f =
981980 maxA = maxBound @a
982981 minB = minBound @b
983982 maxB = maxBound @b
984− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
985− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
983+ ccols = fromInteger $ natVal (Proxy :: Proxy (Count a))
984+ rrows = fromInteger $ natVal (Proxy :: Proxy (Count b))
986985 elementsA = take ccols [minA .. maxA]
987986 elementsB = take rrows [minB .. maxB]
988987 combinations = (,) <$> elementsA <*> elementsB
@@ -1003,7 +1002,7 @@ toRel ::
10031002 Enum a,
10041003 Enum b,
10051004 Eq b,
1006− CountableDimsN a b,
1005+ CountableDims a b,
10071006 FLN b a
10081007 )
10091008 => (a -> b -> Bool) -> Relation (Normalize a) (Normalize b)
@@ -1012,8 +1011,8 @@ toRel f =
10121011 maxA = maxBound @a
10131012 minB = minBound @b
10141013 maxB = maxBound @b
1015− ccols = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize a)))
1016− rrows = fromInteger $ natVal (Proxy :: Proxy (Count (Normalize b)))
1014+ ccols = fromInteger $ natVal (Proxy :: Proxy (Count a))
1015+ rrows = fromInteger $ natVal (Proxy :: Proxy (Count b))
10171016 elementsA = take ccols [minA .. maxA]
10181017 elementsB = take rrows [minB .. maxB]
10191018 combinations = (,) <$> elementsA <*> elementsB
src/LAoP/Matrix/Type.hs+7−7
@@ -215,8 +215,8 @@ instance (Num e) => Category (Matrix e) where
215215bimapM ::
216216 ( Liftable e a b,
217217 Liftable e c d,
218− CountableDimsN a c,
219− CountableDimsN b d,
218+ CountableDims a c,
219+ CountableDims b d,
220220 FLN d c,
221221 FLN b a
222222 ) => (a -> b) -> (c -> d) -> Matrix e a c -> Matrix e b d
@@ -269,7 +269,7 @@ infixl 2 ===
269269-- | Functor instance equivalent function
270270fmapM ::
271271 ( Liftable e a b,
272− CountableDimsN a b,
272+ CountableDims a b,
273273 FLN b a
274274 )
275275 =>
@@ -333,7 +333,7 @@ matrixBuilder ::
333333 Bounded a,
334334 Bounded b,
335335 Eq a,
336− CountableDimsN a b
336+ Countable b
337337 ) => ((a, b) -> e) -> Matrix e a b
338338matrixBuilder f = M (I.matrixBuilder f)
339339
@@ -361,7 +361,7 @@ fromF' = M . I.fromF'
361361-- cardinality's.
362362fromF ::
363363 ( Liftable e a b,
364− CountableDimsN a b,
364+ CountableDims a b,
365365 FLN b a
366366 ) =>
367367 (a -> b) -> Matrix e a b
@@ -370,7 +370,7 @@ fromF = M . I.fromF
370370-- | Lifts relation functions to Boolean Matrix
371371toRel ::
372372 ( Liftable (Natural 0 1) a b,
373− CountableDimsN a b,
373+ CountableDims a b,
374374 FLN b a
375375 ) => (a -> b -> Bool) -> Matrix (Natural 0 1) a b
376376toRel = M . I.toRel
@@ -428,7 +428,7 @@ point ::
428428 Eq a,
429429 Num e,
430430 Ord e,
431− CountableN a,
431+ Countable a,
432432 FLN a One
433433 ) => a -> Matrix e One a
434434point = fromF . const
src/LAoP/Relation/Internal.hs+17−14
@@ -283,7 +283,7 @@ relationBuilder ::
283283 Bounded a,
284284 Bounded b,
285285 Eq a,
286− CountableDimsN a b
286+ CountableDims a b
287287 ) => ((a, b) -> Boolean) -> Relation a b
288288relationBuilder = R . I.matrixBuilder
289289
@@ -301,9 +301,9 @@ fromF' f = R (I.fromFRel' f)
301301
302302-- | Lifts functions to matrices with dimensions matching @a@ and @b@
303303-- cardinality's.
304−fromF ::
304+fromF ::
305305 ( Liftable a b,
306− CountableDimsN a b,
306+ CountableDims a b,
307307 FLN b a
308308 )
309309 => (a -> b) -> Relation a b
@@ -312,7 +312,7 @@ fromF f = R (I.fromFRel f)
312312-- | Lifts relation functions to 'Relation'
313313toRel ::
314314 ( Liftable a b,
315− CountableDimsN a b,
315+ CountableDims a b,
316316 FLN b a
317317 )
318318 => (a -> b -> Bool) -> Relation a b
@@ -322,7 +322,7 @@ toRel = R . I.toRel
322322fromRel ::
323323 ( Liftable a b,
324324 Eq a,
325− CountableDimsN a b,
325+ CountableDims a b,
326326 FLN a One,
327327 FLN b One
328328 )
@@ -351,7 +351,7 @@ toBool r = case toList r of
351351pt ::
352352 ( Liftable a b,
353353 Eq a,
354− CountableDimsN a b,
354+ CountableDims a b,
355355 FLN a One,
356356 FLN b One
357357 )
@@ -365,7 +365,7 @@ belongs ::
365365 ( Bounded a,
366366 Enum a,
367367 Eq a,
368− CountableDimsN (List a) a,
368+ CountableDims (List a) a,
369369 FLN a (List a)
370370 )
371371 => Relation (List a) a
@@ -413,11 +413,11 @@ bang ::
413413bang = ones
414414
415415-- | Point constant relation
416−point ::
416+point ::
417417 ( Bounded a,
418418 Enum a,
419419 Eq a,
420− CountableN a,
420+ Countable a,
421421 FLN a One
422422 ) => a -> Relation One a
423423point = fromF . const
@@ -496,7 +496,7 @@ overriddenBy r s = s `union` r `intersection` divR zeros (conv s)
496496pointAp ::
497497 ( Liftable a b,
498498 Eq a,
499− CountableDimsN a b,
499+ CountableDims a b,
500500 FLN a One,
501501 FLN b One
502502 ) => a -> b -> Relation a b -> Relation One One
@@ -508,7 +508,7 @@ pointAp a b r = conv (point b) . r . point a
508508pointApBool ::
509509 ( Liftable a b,
510510 Eq a,
511− CountableDimsN a b,
511+ CountableDims a b,
512512 FLN a One,
513513 FLN b One
514514 ) => a -> b -> Relation a b -> Bool
@@ -927,6 +927,7 @@ untrans s = fstR . conv (splitR (conv s) sndR)
927927predR ::
928928 ( Bounded a,
929929 Enum a,
930+ Countable a,
930931 CountableN a,
931932 FLN a a,
932933 FLN Bool a
@@ -954,23 +955,25 @@ equalizer f g = id `intersection` divisionF f g
954955-- @
955956-- 'guard' p = 'i2' ``overriddenBy`` 'i1' `.` 'predR' p
956957-- @
957−guard ::
958+guard ::
958959 ( Bounded b,
959960 Enum b,
960961 CountableN b,
962+ Countable b,
961963 FLN b b,
962964 FLN Bool b
963965 ) => Relation b Bool -> Relation b (Either b b)
964966guard p = conv (eitherR (predR p) (predR (negate p)))
965967
966968-- | Relational McCarthy's conditional.
967−cond ::
969+cond ::
968970 ( Bounded b,
969971 Enum b,
972+ Countable b,
970973 CountableN b,
971974 FLN b b,
972975 FLN Bool b
973− )
976+ )
974977 => Relation b Bool -> Relation b c -> Relation b c -> Relation b c
975978cond p r s = eitherR r s . guard p
976979