on master help sign in
Updated select's operator type
6fa500dArmando Santos
src/Matrix/Internal.hs+2−17
@@ -695,23 +695,8 @@ tr (Split a b) = Junc (tr a) (tr b)
695
695
696-- | Selective functors 'select' operator equivalent inspired by the
696-- | Selective functors 'select' operator equivalent inspired by the
697-- ArrowMonad solution presented in the paper.
697-- ArrowMonad solution presented in the paper.
698−select ::
699− ( Bounded a,
700− Bounded b,
701− Enum a,
702− Enum b,
703− Num e,
704− Ord e,
705− Eq b,
706− KnownNat (Count (Normalize a)),
707− KnownNat (Count (Normalize b)),
708− KnownNat (Count cols),
709− FromLists e (Normalize b) (Normalize a),
710− FromLists e (Normalize b) (Normalize b)
711− ) => Matrix e cols (Either (Normalize a) (Normalize b)) -> (a -> b) -> Matrix e cols (Normalize b)
698+select :: (Num e, FromLists e b b, KnownNat (Count b)) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
712−select m y =
713− let f = fromF y
714− in junc f identity . m
699+select m y = junc y identity . m
715
700
716-- McCarthy's Conditional
701-- McCarthy's Conditional
717
702
src/Matrix/Nat.hs+9−14
@@ -447,20 +447,15 @@ tr :: Matrix e cols rows -> Matrix e rows cols
447tr (M m) = M (I.tr m)
447tr (M m) = M (I.tr m)
448
448
449-- Selective 'select' operator
449-- Selective 'select' operator
450−--
450+select ::
451−select :: (Bounded a, Bounded b, Enum a, Enum b, Num e, Ord e,
451+ ( Num e,
452− KnownNat (I.Count (I.FromNat (I.Count a))),
452+ I.FromLists e (I.FromNat rows1) (I.FromNat rows1),
453− KnownNat (I.Count (I.FromNat (I.Count b))),
454− KnownNat (I.Count (I.FromNat cols1)),
453+ KnownNat (I.Count (I.FromNat rows1)),
455− I.FromLists e (I.FromNat (I.Count b)) (I.FromNat (I.Count a)),
454+ I.FromNat rows2 ~ I.FromNat rows1,
456− I.FromLists e (I.FromNat (I.Count b)) (I.FromNat (I.Count b)),
455+ I.FromNat cols1 ~ I.FromNat cols2,
457− Eq b,
458− I.FromNat rows1
459− ~ Either (I.FromNat (I.Count a)) (I.FromNat (I.Count b)),
456+ I.FromNat rows3 ~ Either (I.FromNat cols3) (I.FromNat rows1)
460− I.FromNat cols2 ~ I.FromNat cols1,
461− I.FromNat (I.Count b) ~ I.FromNat rows2) =>
462− Matrix e cols1 rows1 -> (a -> b) -> Matrix e cols2 rows2
457+ ) => Matrix e cols1 rows3 -> Matrix e cols3 rows1 -> Matrix e cols2 rows2
463−select (M m) y = M (I.select m y)
458+select (M m) (M y) = M (I.select m y)
464
459
465-- McCarthy's Conditional
460-- McCarthy's Conditional
466
461
src/Matrix/Type.hs+4−14
@@ -545,22 +545,12 @@ tr (M m) = M (I.tr m)
545-- | Selective functors 'select' operator equivalent inspired by the
545-- | Selective functors 'select' operator equivalent inspired by the
546-- ArrowMonad solution presented in the paper.
546-- ArrowMonad solution presented in the paper.
547select ::
547select ::
548− ( Bounded a,
549− Bounded b,
550− Enum a,
551− Eq b,
552− Enum b,
553− Num e,
548+ ( Num e,
554− Ord e,
555− KnownNat (I.Count (I.Normalize a)),
556− KnownNat (I.Count (I.Normalize b)),
557− KnownNat (I.Count (I.Normalize cols)),
558− I.FromLists e (I.Normalize b) (I.Normalize a),
559 I.FromLists e (I.Normalize b) (I.Normalize b),
549 I.FromLists e (I.Normalize b) (I.Normalize b),
550+ KnownNat (I.Count (I.Normalize b)),
560 I.Normalize (Either a b) ~ Either (I.Normalize a) (I.Normalize b)
551 I.Normalize (Either a b) ~ Either (I.Normalize a) (I.Normalize b)
561− )
562− => Matrix e cols (Either a b) -> (a -> b) -> Matrix e cols b
552+ ) => Matrix e cols (Either a b) -> Matrix e a b -> Matrix e cols b
563−select (M m) y = M (I.select m y)
553+select (M m) (M y) = M (I.select m y)
564
554
565-- McCarthy's Conditional
555-- McCarthy's Conditional
566
556