iface: add class `SumFunctor`
authorJulien Moutinho <julm+symantic-base@sourcephile.fr>
Sun, 5 Sep 2021 17:51:09 +0000 (19:51 +0200)
committerJulien Moutinho <julm+symantic-base@sourcephile.fr>
Wed, 27 Oct 2021 22:08:31 +0000 (00:08 +0200)
src/Symantic/Lang.hs

index 45fb31a63dec0c352bae742e53235bbc15fe4e86..692ec723833fa038989a27d51778d64bd16542de 100644 (file)
@@ -175,11 +175,19 @@ class ProductFunctor repr where
     FromDerived2 ProductFunctor repr =>
     repr a -> repr b -> repr (a, b)
 
--- * Class 'AlternativeFunctor'
-class AlternativeFunctor repr where
-  (<+>) :: repr a -> repr a -> repr a
+-- * Class 'SumFunctor'
+class SumFunctor repr where
+  (<+>) :: repr a -> repr b -> repr (Either a b)
   (<+>) = liftDerived2 (<+>)
   default (<+>) ::
+    FromDerived2 SumFunctor repr =>
+    repr a -> repr b -> repr (Either a b)
+
+-- * Class 'AlternativeFunctor'
+class AlternativeFunctor repr where
+  (<|>) :: repr a -> repr a -> repr a
+  (<|>) = liftDerived2 (<|>)
+  default (<|>) ::
     FromDerived2 AlternativeFunctor repr =>
     repr a -> repr a -> repr a