@@ -89,8 +89,8 @@ module LAoP.Matrix.Internal
8989 cond,
9090
9191 -- ** Matrix "abiding"
92− abideJS,
93− abideSJ,
92+ abideJF,
93+ abideFJ,
9494
9595 -- ** Zip matrices
9696 zipWithM,
@@ -119,7 +119,7 @@ module LAoP.Matrix.Internal
119119 sndM,
120120
121121 -- *** Matrix pairing
122− khatri,
122+ kr,
123123
124124 -- * Matrix composition and lifting
125125
@@ -228,22 +228,22 @@ type Trivial a = FromNat (Count a) ~ a
228228--
229229-- Please use 'iden' instead.
230230instance (Num e) => Category (Matrix e) where
231− id = undefined
231+ id = undefined
232232 (.) = comp
233233
234234instance NFData e => NFData (Matrix e cols rows) where
235− rnf Empty = ()
236− rnf (One e) = rnf e
235+ rnf Empty = ()
236+ rnf (One e) = rnf e
237237 rnf (Join a b) = rnf a `seq` rnf b
238238 rnf (Fork a b) = rnf a `seq` rnf b
239239
240240instance Eq e => Eq (Matrix e cols rows) where
241− Empty == Empty = True
242− (One a) == (One b) = a == b
243− (Join a b) == (Join c d) = a == c && b == d
244− (Fork a b) == (Fork c d) = a == c && b == d
245− x@(Fork _ _) == y@(Join _ _) = x == abideJS y
246− x@(Join _ _) == y@(Fork _ _) = abideJS x == y
241+ Empty == Empty = True
242+ (One a) == (One b) = a == b
243+ (Join a b) == (Join c d) = a == c && b == d
244+ (Fork a b) == (Fork c d) = a == c && b == d
245+ x@(Fork _ _) == y@(Join _ _) = x == abideJF y
246+ x@(Join _ _) == y@(Fork _ _) = abideJF x == y
247247
248248instance Num e => Num (Matrix e cols rows) where
249249
@@ -253,23 +253,23 @@ instance Num e => Num (Matrix e cols rows) where
253253
254254 a * b = zipWithM (*) a b
255255
256− abs Empty = Empty
257− abs (One a) = One (abs a)
258− abs (Join a b) = Join (abs a) (abs b)
256+ abs Empty = Empty
257+ abs (One a) = One (abs a)
258+ abs (Join a b) = Join (abs a) (abs b)
259259 abs (Fork a b) = Fork (abs a) (abs b)
260260
261− signum Empty = Empty
262− signum (One a) = One (signum a)
263− signum (Join a b) = Join (signum a) (signum b)
261+ signum Empty = Empty
262+ signum (One a) = One (signum a)
263+ signum (Join a b) = Join (signum a) (signum b)
264264 signum (Fork a b) = Fork (signum a) (signum b)
265265
266266instance Ord e => Ord (Matrix e cols rows) where
267− Empty <= Empty = True
268− (One a) <= (One b) = a <= b
269− (Join a b) <= (Join c d) = (a <= c) && (b <= d)
270− (Fork a b) <= (Fork c d) = (a <= c) && (b <= d)
271− x@(Fork _ _) <= y@(Join _ _) = x <= abideJS y
272− x@(Join _ _) <= y@(Fork _ _) = abideJS x <= y
267+ Empty <= Empty = True
268+ (One a) <= (One b) = a <= b
269+ (Join a b) <= (Join c d) = (a <= c) && (b <= d)
270+ (Fork a b) <= (Fork c d) = (a <= c) && (b <= d)
271+ x@(Fork _ _) <= y@(Join _ _) = x <= abideJF y
272+ x@(Join _ _) <= y@(Fork _ _) = abideJF x <= y
273273
274274-- Primitives
275275
@@ -325,7 +325,7 @@ instance {-# OVERLAPPING #-} (FromLists e cols ()) => FromLists e (Either () col
325325 fromLists _ = error "Wrong dimensions"
326326
327327instance {-# OVERLAPPABLE #-} (FromLists e a (), FromLists e b (), Countable a) => FromLists e (Either a b) () where
328− fromLists [l] =
328+ fromLists [l] =
329329 let rowsA = fromInteger (natVal (Proxy :: Proxy (Count a)))
330330 in Join (fromLists [take rowsA l]) (fromLists [drop rowsA l])
331331 fromLists _ = error "Wrong dimensions"
@@ -355,9 +355,7 @@ matrixBuilder ::
355355 forall e cols rows.
356356 ( FromLists e cols rows,
357357 CountableDimensions cols rows
358− ) =>
359− ((Int, Int) -> e) ->
360− Matrix e cols rows
358+ ) => ((Int, Int) -> e) -> Matrix e cols rows
361359matrixBuilder f =
362360 let c = fromInteger $ natVal (Proxy :: Proxy (Count cols))
363361 r = fromInteger $ natVal (Proxy :: Proxy (Count rows))
@@ -394,8 +392,8 @@ fromF' f =
394392 elementsA = take ccols [minA .. maxA]
395393 elementsB = take rrows [minB .. maxB]
396394 combinations = (,) <$> elementsA <*> elementsB
397− combAp = map snd . sort . map (\(a, b) -> if f a == b
398− then ((fromEnum a, fromEnum b), 1)
395+ combAp = map snd . sort . map (\(a, b) -> if f a == b
396+ then ((fromEnum a, fromEnum b), 1)
399397 else ((fromEnum a, fromEnum b), 0)) $ combinations
400398 mList = buildList combAp rrows
401399 in tr $ fromLists mList
@@ -423,8 +421,8 @@ fromF f =
423421 elementsA = take ccols [minA .. maxA]
424422 elementsB = take rrows [minB .. maxB]
425423 combinations = (,) <$> elementsA <*> elementsB
426− combAp = map snd . sort . map (\(a, b) -> if f a == b
427− then ((fromEnum a, fromEnum b), 1)
424+ combAp = map snd . sort . map (\(a, b) -> if f a == b
425+ then ((fromEnum a, fromEnum b), 1)
428426 else ((fromEnum a, fromEnum b), 0)) $ combinations
429427 mList = buildList combAp rrows
430428 in tr $ fromLists mList
@@ -488,11 +486,11 @@ iden = matrixBuilder (bool 0 1 . uncurry (==))
488486-- This definition takes advantage of divide-and-conquer and fusion laws
489487-- from LAoP.
490488comp :: (Num e) => Matrix e cr rows -> Matrix e cols cr -> Matrix e cols rows
491−comp Empty Empty = Empty
492−comp (One a) (One b) = One (a * b)
489+comp Empty Empty = Empty
490+comp (One a) (One b) = One (a * b)
493491comp (Join a b) (Fork c d) = comp a c + comp b d -- Divide-and-conquer law
494492comp (Fork a b) c = Fork (comp a c) (comp b c) -- Fork fusion law
495−comp c (Join a b) = Join (comp c a) (comp c b) -- Join fusion law
493+comp c (Join a b) = Join (comp c a) (comp c b) -- Join fusion law
496494{-# NOINLINE comp #-}
497495{-# RULES
498496 "comp/iden1" forall m. comp m iden = m ;
@@ -569,7 +567,7 @@ infixl 5 -|-
569567-- Khatri Rao Product and projections
570568
571569-- | Khatri Rao product first component projection matrix.
572−fstM ::
570+fstM ::
573571 forall e m k .
574572 ( Num e,
575573 CountableDimensions k m,
@@ -581,10 +579,10 @@ fstM = matrixBuilder f
581579 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
582580 f (x, y)
583581 | y >= (x * offset) && y <= (x * offset + offset - 1) = 1
584− | otherwise = 0
582+ | otherwise = 0
585583
586584-- | Khatri Rao product second component projection matrix.
587−sndM ::
585+sndM ::
588586 forall e m k .
589587 ( Num e,
590588 CountableDimensions k m,
@@ -596,39 +594,39 @@ sndM = matrixBuilder f
596594 offset = fromInteger (natVal (Proxy :: Proxy (Count k)))
597595 f (x, y)
598596 | x == y || mod (y - x) offset == 0 = 1
599− | otherwise = 0
597+ | otherwise = 0
600598
601599-- | Khatri Rao Matrix product also known as matrix pairing.
602600--
603601-- NOTE: That this is not a true categorical product, see for instance:
604602--
605603-- @
606−-- | fstM . khatri a b == a
607−-- khatri a b ==> |
608−-- | sndM . khatri a b == b
604+-- | fstM . kr a b == a
605+-- kr a b ==> |
606+-- | sndM . kr a b == b
609607-- @
610608--
611609-- __Emphasis__ on the implication symbol.
612−khatri ::
613− forall e cols a b.
610+kr ::
611+ forall e cols a b.
614612 ( Num e,
615613 CountableDimensions a b,
616614 CountableN (a, b),
617615 FromLists e (Normalize (a, b)) a,
618616 FromLists e (Normalize (a, b)) b
619617 ) => Matrix e cols a -> Matrix e cols b -> Matrix e cols (Normalize (a, b))
620−khatri a b =
618+kr a b =
621619 let fstM' = fstM @e @a @b
622620 sndM' = sndM @e @a @b
623− in (tr fstM') . a * (tr sndM') . b
621+ in tr fstM' . a * tr sndM' . b
624622
625623-- Product Bifunctor (Kronecker)
626624
627625infixl 4 ><
628626
629627-- | Matrix product functor also known as kronecker product
630−(><) ::
631− forall e m p n q.
628+(><) ::
629+ forall e m p n q.
632630 ( Num e,
633631 CountableDimensions m n,
634632 CountableDimensions p q,
@@ -642,45 +640,45 @@ infixl 4 ><
642640(><) a b =
643641 let fstM' = fstM @e @m @n
644642 sndM' = sndM @e @m @n
645− in khatri (a . fstM') (b . sndM')
643+ in kr (a . fstM') (b . sndM')
646644
647645-- Matrix abide Join Fork
648646
649−-- | Matrix "abiding" followin the 'Join'-'Fork' abide law.
650−--
647+-- | Matrix "abiding" following the 'Join'-'Fork' exchange law.
648+--
651649-- Law:
652650--
653651-- @
654652-- 'Join' ('Fork' a c) ('Fork' b d) == 'Fork' ('Join' a b) ('Join' c d)
655653-- @
656−abideJS :: Matrix e cols rows -> Matrix e cols rows
657−abideJS (Join (Fork a c) (Fork b d)) = Fork (Join (abideJS a) (abideJS b)) (Join (abideJS c) (abideJS d)) -- Join-Fork abide law
658−abideJS Empty = Empty
659−abideJS (One e) = One e
660−abideJS (Join a b) = Join (abideJS a) (abideJS b)
661−abideJS (Fork a b) = Fork (abideJS a) (abideJS b)
654+abideJF :: Matrix e cols rows -> Matrix e cols rows
655+abideJF (Join (Fork a c) (Fork b d)) = Fork (Join (abideJF a) (abideJF b)) (Join (abideJF c) (abideJF d)) -- Join-Fork abide law
656+abideJF Empty = Empty
657+abideJF (One e) = One e
658+abideJF (Join a b) = Join (abideJF a) (abideJF b)
659+abideJF (Fork a b) = Fork (abideJF a) (abideJF b)
662660
663661-- Matrix abide Fork Join
664662
665663-- | Matrix "abiding" followin the 'Fork'-'Join' abide law.
666−--
664+--
667665-- @
668666-- 'Fork' ('Join' a b) ('Join' c d) == 'Join' ('Fork' a c) ('Fork' b d)
669667-- @
670−abideSJ :: Matrix e cols rows -> Matrix e cols rows
671−abideSJ (Fork (Join a b) (Join c d)) = Join (Fork (abideSJ a) (abideSJ c)) (Fork (abideSJ b) (abideSJ d)) -- Fork-Join abide law
672−abideSJ Empty = Empty
673−abideSJ (One e) = One e
674−abideSJ (Join a b) = Join (abideSJ a) (abideSJ b)
675−abideSJ (Fork a b) = Fork (abideSJ a) (abideSJ b)
668+abideFJ :: Matrix e cols rows -> Matrix e cols rows
669+abideFJ (Fork (Join a b) (Join c d)) = Join (Fork (abideFJ a) (abideFJ c)) (Fork (abideFJ b) (abideFJ d)) -- Fork-Join abide law
670+abideFJ Empty = Empty
671+abideFJ (One e) = One e
672+abideFJ (Join a b) = Join (abideFJ a) (abideFJ b)
673+abideFJ (Fork a b) = Fork (abideFJ a) (abideFJ b)
676674
677675-- Matrix transposition
678676
679677-- | Matrix transposition.
680678tr :: Matrix e cols rows -> Matrix e rows cols
681−tr Empty = Empty
682−tr (One e) = One e
683−tr (Join a b) = Fork (tr a) (tr b)
679+tr Empty = Empty
680+tr (One e) = One e
681+tr (Join a b) = Fork (tr a) (tr b)
684682tr (Fork a b) = Join (tr a) (tr b)
685683
686684-- Selective 'select' operator
@@ -688,9 +686,9 @@ tr (Fork a b) = Join (tr a) (tr b)
688686-- | Selective functors 'select' operator equivalent inspired by the
689687-- ArrowMonad solution presented in the paper.
690688select :: (Num e, FromLists e b b, Countable b) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
691−select (Fork a b) y = y . a + b -- Divide-and-conquer law
689+select (Fork a b) y = y . a + b -- Divide-and-conquer law
692690select (Join (Fork a c) (Fork b d)) y = join (y . a + c) (y . b + d) -- Pattern matching + DnC law
693−select m y = join y iden . m
691+select m y = join y iden . m
694692
695693branch ::
696694 ( Num e,
@@ -733,7 +731,7 @@ cond ::
733731 (a -> Bool) -> Matrix e cols rows -> Matrix e cols rows -> Matrix e cols rows
734732cond p f g = join f g . grd p
735733
736−grd ::
734+grd ::
737735 ( Trivial q,
738736 Countable q,
739737 FromLists e () q,
@@ -748,38 +746,38 @@ grd ::
748746 (a -> Bool) -> Matrix e q (Either q q)
749747grd f = fork (corr f) (corr (not . f))
750748
751−corr ::
752− forall e a q .
749+corr ::
750+ forall e a q .
753751 ( Trivial q,
754752 Countable q,
755753 FromLists e () q,
756754 FromLists e q (),
757755 FromLists e q q,
758756 Liftable e a Bool
759− )
757+ )
760758 => (a -> Bool) -> Matrix e q q
761759corr p = let f = fromF' p :: Matrix e q ()
762− in khatri f (iden :: Matrix e q q)
760+ in kr f (iden :: Matrix e q q)
763761
764762-- Pretty print
765763
766764prettyAux :: Show e => [[e]] -> [[e]] -> String
767765prettyAux [] _ = ""
768−prettyAux [[e]] m = "│ " ++ fill (show e) ++ " │\n"
766+prettyAux [[e]] m = "│ " ++ fill (show e) ++ " │\n"
769767 where
770768 v = fmap show m
771769 widest = maximum $ fmap length v
772770 fill str = replicate (widest - length str - 2) ' ' ++ str
773−prettyAux [h] m = "│ " ++ fill (unwords $ map show h) ++ " │\n"
771+prettyAux [h] m = "│ " ++ fill (unwords $ map show h) ++ " │\n"
774772 where
775− v = fmap show m
776− widest = maximum $ fmap length v
773+ v = fmap show m
774+ widest = maximum $ fmap length v
777775 fill str = replicate (widest - length str - 2) ' ' ++ str
778−prettyAux (h : t) l = "│ " ++ fill (unwords $ map show h) ++ " │\n" ++
776+prettyAux (h : t) l = "│ " ++ fill (unwords $ map show h) ++ " │\n" ++
779777 prettyAux t l
780778 where
781− v = fmap show l
782− widest = maximum $ fmap length v
779+ v = fmap show l
780+ widest = maximum $ fmap length v
783781 fill str = replicate (widest - length str - 2) ' ' ++ str
784782
785783-- | Matrix pretty printer
@@ -791,16 +789,16 @@ pretty m = concat
791789 , "└ ", unwords (replicate (columns m) blank), " ┘"
792790 ]
793791 where
794− strings = map show (toList m)
795− widest = maximum $ map length strings
792+ strings = map show (toList m)
793+ widest = maximum $ map length strings
796794 fill str = replicate (widest - length str) ' ' ++ str
797− blank = fill ""
795+ blank = fill ""
798796 safeGet i j m
799797 | i > rows m || j > columns m || i < 1 || j < 1 = Nothing
800798 | otherwise = Just $ unsafeGet i j m (toList m)
801799 unsafeGet i j m l = l !! encode (columns m) (i,j)
802− encode m (i,j) = (i-1)*m + j - 1
803− getElem i j m =
800+ encode m (i,j) = (i-1)*m + j - 1
801+ getElem i j m =
804802 fromMaybe
805803 (error $
806804 "getElem: Trying to get the "
@@ -817,16 +815,16 @@ prettyPrint = putStrLn . pretty
817815
818816-- | Zip two matrices with a given binary function
819817zipWithM :: (e -> f -> g) -> Matrix e cols rows -> Matrix f cols rows -> Matrix g cols rows
820−zipWithM f Empty Empty = Empty
821−zipWithM f (One a) (One b) = One (f a b)
822−zipWithM f (Join a b) (Join c d) = Join (zipWithM f a c) (zipWithM f b d)
823−zipWithM f (Fork a b) (Fork c d) = Fork (zipWithM f a c) (zipWithM f b d)
824−zipWithM f x@(Fork _ _) y@(Join _ _) = zipWithM f x (abideJS y)
825−zipWithM f x@(Join _ _) y@(Fork _ _) = zipWithM f (abideJS x) y
818+zipWithM _ Empty Empty = Empty
819+zipWithM f (One a) (One b) = One (f a b)
820+zipWithM f (Join a b) (Join c d) = Join (zipWithM f a c) (zipWithM f b d)
821+zipWithM f (Fork a b) (Fork c d) = Fork (zipWithM f a c) (zipWithM f b d)
822+zipWithM f x@(Fork _ _) y@(Join _ _) = zipWithM f x (abideJF y)
823+zipWithM f x@(Join _ _) y@(Fork _ _) = zipWithM f (abideJF x) y
826824
827825-- Relational operators functions
828826
829−type Boolean = Natural 0 1
827+type Boolean = Natural 0 1
830828type Relation a b = Matrix Boolean a b
831829
832830-- | Helper conversion function
@@ -843,53 +841,52 @@ fromBool False = nat 0
843841-- | Relational negation
844842negateM :: Relation cols rows -> Relation cols rows
845843negateM Empty = Empty
846−negateM (One (Nat 0)) = One (Nat 1)
847−negateM (One (Nat 1)) = One (Nat 0)
844+negateM (One (Nat p)) = One (Nat (negate p))
848845negateM (Join a b) = Join (negateM a) (negateM b)
849−negateM (Fork a b) = Fork (negateM a) (negateM b)
846+negateM (Fork a b) = Fork (negateM a) (negateM b)
850847
851848-- | Relational addition
852849orM :: Relation cols rows -> Relation cols rows -> Relation cols rows
853−orM Empty Empty = Empty
854−orM (One a) (One b) = One (fromBool (toBool a || toBool b))
855−orM (Join a b) (Join c d) = Join (orM a c) (orM b d)
856−orM (Fork a b) (Fork c d) = Fork (orM a c) (orM b d)
857−orM x@(Fork _ _) y@(Join _ _) = orM x (abideJS y)
858−orM x@(Join _ _) y@(Fork _ _) = orM (abideJS x) y
850+orM Empty Empty = Empty
851+orM (One a) (One b) = One (fromBool (toBool a || toBool b))
852+orM (Join a b) (Join c d) = Join (orM a c) (orM b d)
853+orM (Fork a b) (Fork c d) = Fork (orM a c) (orM b d)
854+orM x@(Fork _ _) y@(Join _ _) = orM x (abideJF y)
855+orM x@(Join _ _) y@(Fork _ _) = orM (abideJF x) y
859856
860857-- | Relational multiplication
861858andM :: Relation cols rows -> Relation cols rows -> Relation cols rows
862−andM Empty Empty = Empty
863−andM (One a) (One b) = One (fromBool (toBool a && toBool b))
864−andM (Join a b) (Join c d) = Join (andM a c) (andM b d)
865−andM (Fork a b) (Fork c d) = Fork (andM a c) (andM b d)
866−andM x@(Fork _ _) y@(Join _ _) = andM x (abideJS y)
867−andM x@(Join _ _) y@(Fork _ _) = andM (abideJS x) y
859+andM Empty Empty = Empty
860+andM (One a) (One b) = One (fromBool (toBool a && toBool b))
861+andM (Join a b) (Join c d) = Join (andM a c) (andM b d)
862+andM (Fork a b) (Fork c d) = Fork (andM a c) (andM b d)
863+andM x@(Fork _ _) y@(Join _ _) = andM x (abideJF y)
864+andM x@(Join _ _) y@(Fork _ _) = andM (abideJF x) y
868865
869866-- | Relational subtraction
870867subM :: Relation cols rows -> Relation cols rows -> Relation cols rows
871−subM Empty Empty = Empty
872−subM (One a) (One b) = if a - b < nat 0 then One (nat 0) else One (a - b)
873−subM (Join a b) (Join c d) = Join (subM a c) (subM b d)
874−subM (Fork a b) (Fork c d) = Fork (subM a c) (subM b d)
875−subM x@(Fork _ _) y@(Join _ _) = subM x (abideJS y)
876−subM x@(Join _ _) y@(Fork _ _) = subM (abideJS x) y
868+subM Empty Empty = Empty
869+subM (One a) (One b) = if a - b < nat 0 then One (nat 0) else One (a - b)
870+subM (Join a b) (Join c d) = Join (subM a c) (subM b d)
871+subM (Fork a b) (Fork c d) = Fork (subM a c) (subM b d)
872+subM x@(Fork _ _) y@(Join _ _) = subM x (abideJF y)
873+subM x@(Join _ _) y@(Fork _ _) = subM (abideJF x) y
877874
878875-- | Matrix relational composition.
879876compRel :: Relation cr rows -> Relation cols cr -> Relation cols rows
880−compRel Empty Empty = Empty
881−compRel (One a) (One b) = One (fromBool (toBool a && toBool b))
877+compRel Empty Empty = Empty
878+compRel (One a) (One b) = One (fromBool (toBool a && toBool b))
882879compRel (Join a b) (Fork c d) = orM (compRel a c) (compRel b d) -- Divide-and-conquer law
883880compRel (Fork a b) c = Fork (compRel a c) (compRel b c) -- Fork fusion law
884−compRel c (Join a b) = Join (compRel c a) (compRel c b) -- Join fusion law
881+compRel c (Join a b) = Join (compRel c a) (compRel c b) -- Join fusion law
885882
886883-- | Matrix relational right division
887884divR :: Relation b c -> Relation b a -> Relation a c
888885divR Empty Empty = Empty
889886divR (One a) (One b) = One (fromBool (not (toBool b) || toBool a)) -- b implies a
890887divR (Join a b) (Join c d) = andM (divR a c) (divR b d)
891−divR (Fork a b) c = Fork (divR a c) (divR b c)
892−divR c (Fork a b) = Join (divR c a) (divR c b)
888+divR (Fork a b) c = Fork (divR a c) (divR b c)
889+divR c (Fork a b) = Join (divR c a) (divR c b)
893890
894891-- | Matrix relational left division
895892divL :: Relation c b -> Relation a b -> Relation a c
@@ -923,8 +920,8 @@ fromFRel' f =
923920 elementsA = take ccols [minA .. maxA]
924921 elementsB = take rrows [minB .. maxB]
925922 combinations = (,) <$> elementsA <*> elementsB
926− combAp = map snd . sort . map (\(a, b) -> if f a == b
927− then ((fromEnum a, fromEnum b), nat 1)
923+ combAp = map snd . sort . map (\(a, b) -> if f a == b
924+ then ((fromEnum a, fromEnum b), nat 1)
928925 else ((fromEnum a, fromEnum b), nat 0)) $ combinations
929926 mList = buildList combAp rrows
930927 in tr $ fromLists mList
@@ -952,8 +949,8 @@ fromFRel f =
952949 elementsA = take ccols [minA .. maxA]
953950 elementsB = take rrows [minB .. maxB]
954951 combinations = (,) <$> elementsA <*> elementsB
955− combAp = map snd . sort . map (\(a, b) -> if f a == b
956− then ((fromEnum a, fromEnum b), nat 1)
952+ combAp = map snd . sort . map (\(a, b) -> if f a == b
953+ then ((fromEnum a, fromEnum b), nat 1)
957954 else ((fromEnum a, fromEnum b), nat 0)) $ combinations
958955 mList = buildList combAp rrows
959956 in tr $ fromLists mList
@@ -962,7 +959,7 @@ fromFRel f =
962959 buildList l r = take r l : buildList (drop r l) r
963960
964961-- | Lifts a relation function to a Boolean Matrix
965−toRel ::
962+toRel ::
966963 forall a b.
967964 ( Bounded a,
968965 Bounded b,
@@ -983,8 +980,8 @@ toRel f =
983980 elementsA = take ccols [minA .. maxA]
984981 elementsB = take rrows [minB .. maxB]
985982 combinations = (,) <$> elementsA <*> elementsB
986− combAp = map snd . sort . map (\(a, b) -> if uncurry f (a, b)
987− then ((fromEnum a, fromEnum b), nat 1)
983+ combAp = map snd . sort . map (\(a, b) -> if uncurry f (a, b)
984+ then ((fromEnum a, fromEnum b), nat 1)
988985 else ((fromEnum a, fromEnum b), nat 0)) $ combinations
989986 mList = buildList combAp rrows
990987 in tr $ fromLists mList