-1

In Haskell, Monads are defined by kleisli triple.

In Category theory in general, is it fine to say:

Monads = Functors + Idempotency of the monadic type (not the value)?

  • Hi, you should visit [Programmers.SE](https://softwareengineering.stackexchange.com/tour) or [CS.SE](https://cs.stackexchange.com/tour) for questions not specific to any source code. Also please take a [Tour](https://stackoverflow.com/tour). – snipsnipsnip Oct 26 '18 at 01:57
  • Is this related to https://stackoverflow.com/questions/52973336/monads-not-with-flatmap-but-flatunit ? – jberryman Oct 26 '18 at 02:40
  • 1
    @jberryman Presumably it is a follow-up to that one (cf. the comments to the answer there). Note that the rollback war on that question appears to have caused a 24-hour suspension of the OP. – duplode Oct 26 '18 at 02:44

1 Answers1

7

No, a monad is emphatically not idempotent: although there is a requirement that there be a natural transformation

mu_x : T(T(x)) -> T(x)

it is in general not the case that the two objects selected in this way are equal, that is,

T(T(x)) = T(x)

does not generally hold, even up to isomorphism.

Even in the restricted land of Haskell Monad it is easy to see this in action: Maybe (Maybe ()) and Maybe () are clearly inequal types with different numbers of semantic objects; ignoring bottoms:

Nothing, Just () -- Maybe ()
Nothing, Just Nothing, Just (Just ()) -- Maybe (Maybe ())

or with bottoms:

_|_, Nothing, Just _|_, Just () -- Maybe ()
_|_, Nothing, Just _|_, Just Nothing, Just (Just _|_), Just (Just ()) -- Maybe (Maybe ())
Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Thanks for the answer. I have a question. about "T(T(x)) = T(x) does not generally hold, even up to isomorphism.". I thought that if it's an Identity monad that is isomorohism, `T(T(x)) = T(x)` holds. Am I wrong? –  Oct 28 '18 at 16:58
  • @bayesian-study You are not wrong. But most monads are not the Identity monad. – Daniel Wagner Oct 28 '18 at 17:29
  • "does not generally hold, even up to isomorphism" seems to mean as if `T(T(x)) = T(x)` does Not hold on isomophism identiy monad. –  Oct 29 '18 at 08:37
  • @bayesian-study It means that it does not hold *in general* -- that is, across all monads. – Daniel Wagner Oct 29 '18 at 12:41