[Haskell-beginners] Monad for Pair

Mike Houghton mike_k_houghton at yahoo.co.uk
Tue Nov 17 21:41:20 UTC 2015


I have 
newtype Pair a = P (a, a) deriving (Show)

and have made Monoid, Applicative and Functor instances for it.

I’m a bit stumped with Monad!

instance Monad Pair where
  return x  = P (x, x) 

and I got brain ache with >>= 

And really return x  = P (x, x)  
doesn’t seem correct anyway.

Would someone please write the Monad with an explanation?

Many Thanks


More information about the Beginners mailing list