ref: c012b997e270335f4a24b5b5abe95ea383ba2d37
parent: 173848c9431543f9e54f0a09a37d4aba23087bca
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Wed Sep 25 09:15:29 EDT 2024
Add Monoid for ->
--- a/lib/Data/Monoid/Internal.hs
+++ b/lib/Data/Monoid/Internal.hs
@@ -28,6 +28,14 @@
---------------------
+instance (Monoid b) => Monoid (a -> b) where
+ mempty _ = mempty
+
+instance (Semigroup b) => Semigroup (a -> b) where
+ f <> g = \ x -> f x <> g x
+
+---------------------
+
newtype Endo a = Endo { appEndo :: a -> a }
instance forall a . Semigroup (Endo a) where
@@ -241,6 +249,3 @@
| otherwise = g (x `mappend` x) (y `quot` 2) (x `mappend` z)
---------------------
-
-instance (Semigroup b) => Semigroup (a -> b) where
- f <> g = \ x -> f x <> g x