Thanks and Best Regards,
Ahmad Ismail
Il 13 novembre 2022 alle 20:56 Ahmad Ismail ha scritto:
> How can I fix it so that `ItDoesnt <*> WhatThisIsCalled` works?
>
> I have came up with a solution without WhatThisIsCalled
>
> data WhoCares a = ItDoesnt | Matter a deriving (Eq, Show)
>
> instance Functor WhoCares where
> fmap _ ItDoesnt = ItDoesnt
> fmap f (Matter a) = Matter (f a)
>
> instance Applicative WhoCares where
> pure = Matter
> Matter f <*> Matter a = Matter (f a)
> ItDoesnt <*> _ = ItDoesnt
> _ <*> ItDoesnt = ItDoesnt
>
> instance Monad WhoCares where
> return x = Matter x
> (Matter x) >>= k = k x
> ItDoesnt >>= _ = ItDoesnt
This makes much more sense. Now <*> is total and >>= is meaningful,
well done!
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners