[Haskell-beginners] Monad for Pair

Mike Houghton mike_k_houghton at yahoo.co.uk
Wed Nov 18 18:33:59 UTC 2015


'Much better if you let us know the source of this problem. Is this an exercise from some book / online course?”

The source is just me exploring. 
I first looked at 

data C a = C a deriving (Show)

and made Monad, Applicative, Monoid and Functors for it.

So then tried 
Pair a = P (a, a)  
and stuck on Monad.

Thanks	

Mike

> On 18 Nov 2015, at 07:23, Kim-Ee Yeoh <ky3 at atamo.com <mailto:ky3 at atamo.com>> wrote:
> 
> 
> On Wed, Nov 18, 2015 at 4:41 AM, Mike Houghton <mike_k_houghton at yahoo.co.uk <mailto:mike_k_houghton at yahoo.co.uk>> wrote:
> 
> And really return x  = P (x, x) doesn’t seem correct anyway.
> 
> But if you look at the type, which is essentially "a -> (a,a)" there's only one way to write it, for the same reason that there's only one "a -> a" function.
> 
> Would someone please write the Monad with an explanation?
> 
> Much better if you let us know the source of this problem. Is this an exercise from some book / online course?
> 
> -- Kim-Ee
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org <mailto:Beginners at haskell.org>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151118/9b346e6a/attachment.html>


More information about the Beginners mailing list