0

So far I have found:

http://monads.haskell.cz/html/writermonad.html
http://en.wikipedia.org/wiki/Monad_(functional_programming)

which give definitions for >>= and return

Where is the official code?

haroldcarr
  • 1,523
  • 15
  • 17

2 Answers2

6

The Monad instances for the standard transformers are found in the transformers package. For WriterT, look here. Unfortunately, at the moment there's not good tool support for finding where a particular instance is defined -- you just have to do some educated guesswork (or be clever with your favorite grep replacement).

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Great - that's it. I'm just learning the details of individual monads so having been going directly to their files - haven't looked into the `transformers` package yet --- looks like I need to put that on my TODO list. Thanks! – haroldcarr Nov 23 '13 at 03:00
  • BTW: your link had `#line-124`. Is there some way to get those anchors besides manually inspecting the HTML source? – haroldcarr Nov 23 '13 at 03:14
  • 1
    @haroldcarr Well, there's only a few different kinds of anchors haddock produces, and it's possible to know them all. I'm not claiming I do, but here's a handful of useful ones: `#v:name` for the place that defines the value `name`; `#t:name` for the place that defines the type `name`; and `#line-n` for the line `n`. Since instances don't define a new value or type, you have to use the `#line` form (and hence figure out the line number somehow), but the other two are more predictable. – Daniel Wagner Nov 23 '13 at 16:31
  • I see that in the HTML source. I was hoping for some magic! Very useful info - thanks! – haroldcarr Nov 23 '13 at 18:46
  • BTW @daniel-wagner: now that I understand there is no magic, thanks for taking the time to dig out the line number in your original response! – haroldcarr Nov 24 '13 at 18:31
0

All source can be found on Hackage.

bheklilr
  • 53,530
  • 6
  • 107
  • 163
  • 1
    Yes, I've been there. For example: http://hackage.haskell.org/package/mtl-2.1.2/docs/Control-Monad-Writer-Lazy.html --- but I am having a hard time finding `bind` and `return` - thus the request for help. – haroldcarr Nov 23 '13 at 02:38
  • 1
    That is because the 2.x versions of `mtl` take the concrete implementations from `transformers` (note the `Control.Monad.Trans.Writer.Lazy` import in the source). On its own, `mtl` just adds monad classes such as `MonadWriter`. – duplode Nov 23 '13 at 03:04
  • @duplode Mind if I steal your comment and use it as an answer? – Tarrasch Nov 23 '13 at 14:43
  • @Tarrasch Not at all, feel free to do it. – duplode Nov 23 '13 at 15:42