Hi Matthew, thanks for your response. Your suggestion of writing functions of type Block -> [Block] works, I agree it's idiomatic, and it should cover all the functionality I'd like to write. However, this means I was understanding the code incorrectly, so I'd like to ask a follow-up question to understand things better. The way I understood it, the signature of walk, (a ->a) -> b -> b, meant that a function of type Block -> [Block] would not compile, since that doesn't fit the a -> a bit of the signature. Also in my understanding, the existence of "instance Walkable a b => Walkable a [b]" just describes how `walk` behaves when confronted with a list instead of a single element to apply (f :: a->a) to. I don't see how it's related to what happens when f is of type a->[a]. Could you (or someone else) help me understand and tell me where I'm going wrong? On Mon, Nov 17, 2014 at 12:24 AM, Matthew Pickering < matthewtpickering-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Hi Mark, > > Firstly I tend to regard the null the document model as unnecessary as > most things are stored in lists anyway. I would try to avoid it. > > If you consult the documentation for the traversal functions then you can > see all the ppssible filter types.[1] For example the instance Walkable > Inline Inline means that it's possible to writer a filter with type Inline > -> Inline. > > Also notice that there is an instance Walkable a b => Walkable a [b]. This > means you can also write functions with type Block -> [Block] for example. > A useful idiom is usi g the empty list to completely omit a section of the > document. > > Am I misunderstanding the question? Do you wish to write a filter which > does something to a block depending on the next block for example? If you > have a specific filter you would like to write then I could give more > specific advice. > > [1]: > http://hackage.haskell.org/package/pandoc-types-1.12/docs/Text-Pandoc-Walk.html > On 16 Nov 2014 21:22, "Mark Szepieniec" wrote: > >> I have a complex html document that I've read into pandoc, and I'm trying >> to write filters that will isolate the content I'm after. Some examples of >> this are dropping certain Divs entirely, or replacing Tables by just the >> content of their rows. >> >> I can write filters of the type Pandoc -> Pandoc which is workable for >> changing the top-level structure of a document, but would become very >> tedious when Blocks are nested. I could also write my functions to >> return Null :: Block when removing Blocks, but that doesn't feel like >> the right way to do it. Or is that perhaps precisely why Null is there >> in the first place? >> >> I'd like to be able to write functions of type [Block] -> [Block] to use >> in filters, but I get the error >> >> No instance for (Text.Pandoc.Walk.Walkable [Block] Pandoc). >> >> I tried to think about how to write that instance, but it's hard to >> choose between walking lists of Blocks with applying the function to them. >> >> So I feel I might be either missing something obvious, or going about it >> in the wrong way. Is there perhaps a simple solution to what I want to do? >> Or something that could be worth implementing? >> >> -- >> 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/CAE4-1rWH__%3Dcx1yrY9P85GVjwfenckzEg6UjMTdGQ4HQVCmriw%40mail.gmail.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/CALuQ0m9f2MC-OnKKagOqDnwGkY-c6ug6TCoJrehdhMfyb13%2B-Q%40mail.gmail.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/CAE4-1rXXoM5jM0fKzeusdnVoPCj5PCLxW482xB5XKW3%3D34vXeA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.