From 897ae2da6224e5cbcda150a3e65f374ef5872864 Mon Sep 17 00:00:00 2001 From: pingu Date: Thu, 29 Feb 2024 18:44:41 +0100 Subject: [PATCH] Monad? --- src/GoodList.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/GoodList.hs b/src/GoodList.hs index 0db6ab1..127cd26 100644 --- a/src/GoodList.hs +++ b/src/GoodList.hs @@ -19,6 +19,13 @@ instance Applicative GoodList where (Singleton f) <*> x = fmap f x (Multiple a b c) <*> x = append (append (fmap a x) (b <*> x)) (fmap c x) +-- Needs to be proven +instance Monad GoodList where + return = pure + Empty >>= _ = Empty + Singleton x >>= f = f x + Multiple a b c >>= f = append (append (f a) (b >>= f)) (f c) + instance Semigroup (GoodList a) where (<>) = append