public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Learning Pandoc
@ 2019-05-29  0:02 Eli T. Drumm
       [not found] ` <d7e58b79-185f-4e04-b5a4-20df88b38c8d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Eli T. Drumm @ 2019-05-29  0:02 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1087 bytes --]

What's the best place/way to ask questions about the pandoc source code? I 
know some Haskell and am at the point of trying to solidify my 
understanding of how monads and transformers are used in practice. Someday 
I would really love to be able to contribute to this project, I use it 
myself and I have heard the community is friendly and helpful. However, I 
don't want to spam this group with questions that might be better asked in 
a Haskell group or channel, so I wanted to ask for thoughts first.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d7e58b79-185f-4e04-b5a4-20df88b38c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1525 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Learning Pandoc
       [not found] ` <d7e58b79-185f-4e04-b5a4-20df88b38c8d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-05-29  4:01   ` John MacFarlane
       [not found]     ` <m2v9xt7vug.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: John MacFarlane @ 2019-05-29  4:01 UTC (permalink / raw)
  To: Eli T. Drumm, pandoc-discuss


This is the place to ask!

"Eli T. Drumm" <etd-HaWDhDSyBd4@public.gmane.org> writes:

> What's the best place/way to ask questions about the pandoc source code? I 
> know some Haskell and am at the point of trying to solidify my 
> understanding of how monads and transformers are used in practice. Someday 
> I would really love to be able to contribute to this project, I use it 
> myself and I have heard the community is friendly and helpful. However, I 
> don't want to spam this group with questions that might be better asked in 
> a Haskell group or channel, so I wanted to ask for thoughts first.
>
> Thanks!
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d7e58b79-185f-4e04-b5a4-20df88b38c8d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Learning Pandoc
       [not found]     ` <m2v9xt7vug.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2019-06-01 15:46       ` Eli T. Drumm
       [not found]         ` <76ae887b-b824-4413-8cc3-b20923410b89-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Eli T. Drumm @ 2019-06-01 15:46 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3415 bytes --]

Cool, ok!

So I'm going through how the HTML writer works as a post for my website. 
Right now I'm stuck on this function (in Text.Pandoc.Writers.HTML):

pandocToHtml :: PandocMonad m
             => WriterOptions
             -> Pandoc
             -> StateT WriterState m (Html, Value)
pandocToHtml opts (Pandoc meta blocks) = do
    ⋮
    blocks' <- liftM (mconcat . intersperse (nl opts)) $
                   mapM (elementToHtml Nothing slideLevel opts) sects
    st <- get
    notes <- footnoteSection opts (reverse (stNotes st))
    let thebody = blocks' >> notes
    ⋮
    return (thebody, context)

Both `blocks'` and `notes` are, I think, of type `m Html`, since the values 
on the right of the `<-` are of type `StateT WriterState m Html`. The type 
of the monad `m` here is some instance of `PandocMonad`, like `PandocIO`, 
which is a stack of IO, State, and Except monads. The bit I'm having 
trouble with is the `let thebody = blocks' >> notes` line: I get that we 
pass the errors and state forward in the computation (unsure about 
wording), because that's how `>>` is defined for State and Except, but I 
would expect, at the bottom level, the Html `blocks'` to get `mconcat`ted 
with `notes` to produce `thebody`. But using `>>` means we essentially 
throw the Html within `blocks'` away, right? I mean, probably not right, 
but that's why I'm asking, sorry if this is a dumb question.


On Wednesday, May 29, 2019 at 12:01:25 AM UTC-4, John MacFarlane wrote:
>
>
> This is the place to ask! 
>
> "Eli T. Drumm" <e...-HaWDhDSyBd4@public.gmane.org <javascript:>> writes: 
>
> > What's the best place/way to ask questions about the pandoc source code? 
> I 
> > know some Haskell and am at the point of trying to solidify my 
> > understanding of how monads and transformers are used in practice. 
> Someday 
> > I would really love to be able to contribute to this project, I use it 
> > myself and I have heard the community is friendly and helpful. However, 
> I 
> > don't want to spam this group with questions that might be better asked 
> in 
> > a Haskell group or channel, so I wanted to ask for thoughts first. 
> > 
> > Thanks! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "pandoc-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/d7e58b79-185f-4e04-b5a4-20df88b38c8d%40googlegroups.com. 
>
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/76ae887b-b824-4413-8cc3-b20923410b89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 5604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Learning Pandoc
       [not found]         ` <76ae887b-b824-4413-8cc3-b20923410b89-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-06-01 19:18           ` John MacFarlane
  0 siblings, 0 replies; 4+ messages in thread
From: John MacFarlane @ 2019-06-01 19:18 UTC (permalink / raw)
  To: Eli T. Drumm, pandoc-discuss

"Eli T. Drumm" <etd-HaWDhDSyBd4@public.gmane.org> writes:

> Cool, ok!
>
> So I'm going through how the HTML writer works as a post for my website. 
> Right now I'm stuck on this function (in Text.Pandoc.Writers.HTML):
>
> pandocToHtml :: PandocMonad m
>              => WriterOptions
>              -> Pandoc
>              -> StateT WriterState m (Html, Value)
> pandocToHtml opts (Pandoc meta blocks) = do
>     ⋮
>     blocks' <- liftM (mconcat . intersperse (nl opts)) $
>                    mapM (elementToHtml Nothing slideLevel opts) sects
>     st <- get
>     notes <- footnoteSection opts (reverse (stNotes st))
>     let thebody = blocks' >> notes
>     ⋮
>     return (thebody, context)
>
> Both `blocks'` and `notes` are, I think, of type `m Html`, since the values 
> on the right of the `<-` are of type `StateT WriterState m Html`.

Not quite right.  StateT is a monad transformer, so
(StateT WriterState m) is a monad.  The value of the
left-hand side of <-, then, just has type Html.

> But using `>>` means we essentially 
> throw the Html within `blocks'` away, right?

One might well think so! But look at the blaze-html
library to find out about the Html type.  We learn

type Html = Markup

type Markup = MarkupM ()

So Html is a synonym for MarkupM ().  And that monad
is designed so that you can write things like

mypage = do
  p (toHtml "foo")
  p (toHtml "bar")

and get two paragraphs.  That is, monadic >> behaves
like monoidal concatenation.

See https://jaspervdj.be/blaze/tutorial.html

> I mean, probably not right, 
> but that's why I'm asking, sorry if this is a dumb question.

Not at all!  The way Html is a monad, and the way that
monad works, is a bit confusing!  Your question was a
good one.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2k1e5i078.fsf%40johnmacfarlane.net.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-01 19:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29  0:02 Learning Pandoc Eli T. Drumm
     [not found] ` <d7e58b79-185f-4e04-b5a4-20df88b38c8d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-29  4:01   ` John MacFarlane
     [not found]     ` <m2v9xt7vug.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-06-01 15:46       ` Eli T. Drumm
     [not found]         ` <76ae887b-b824-4413-8cc3-b20923410b89-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-06-01 19:18           ` John MacFarlane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).