Skip to main content
added 127 characters in body
Source Link
David Young
  • 2.4k
  • 2
  • 8
  • 24

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. Also, the let-in in the repeat15 should really be a call to -->. I've simplified that for the purposes of demonstration. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. Likewise, the Haskell name for ;; is >>. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. Likewise, the Haskell name for ;; is >>. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. Also, the let-in in the repeat15 should really be a call to -->. I've simplified that for the purposes of demonstration. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. Likewise, the Haskell name for ;; is >>. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

added 55 characters in body
Source Link
David Young
  • 2.4k
  • 2
  • 8
  • 24

I've only described part of one specific monad here. I believe to learn them properly you must experiment with a variety of them. For example, look at the list monad, the reader monad and the proxy monad. There are plenty more, but that is some variety to start with. Think about how the "bind" operation works for each of them works, in each particular case.

I believe to learn them properly you must experiment with a variety of them. For example, look at the list monad, the reader monad and the proxy monad. There are plenty more, but that is some variety to start with. Think about how the "bind" operation works for each of them works, in each particular case.

I've only described part of one specific monad here. I believe to learn them properly you must experiment with a variety of them. For example, look at the list monad, the reader monad and the proxy monad. There are plenty more, but that is some variety to start with. Think about how the "bind" operation works for each of them works, in each particular case.

edited body
Source Link
David Young
  • 2.4k
  • 2
  • 8
  • 24

I've only scratched the surface of a particular monad here. But, but hopefully this answer can provide some useful ideas.

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. Likewise, the Haskell name for ;; is >>. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

I've only scratched the surface of a particular monad here. But hopefully this answer can provide some useful ideas.

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

I've only scratched the surface of a particular monad here, but hopefully this answer can provide some useful ideas.

The particular monad I've described is roughly like Haskell's IO monad, though I've left all calls to writeIORef, readIORef and newIORef implicit. There are many other monads, as well. It remains the case that --> is the basic "action combining" operation. In Haskell, this is called >>=. Likewise, the Haskell name for ;; is >>. There's also an operation that will take a "regular value" and give you an action that simply produces that value without doing anything else. This is sometimes called (in Haskell) pure or (confusingly) return. It's also sometimes called "unit."

Source Link
David Young
  • 2.4k
  • 2
  • 8
  • 24
Loading