1
votes

What am I trying to do ?

Print under ghci the association list of formats and writers.
See doc :

writers :: [(String, Writer)]
Association list of formats and writers. 

What has been tried

zurgl>>>import Text.Pandoc as P
zurgl>>>P.writers 

<interactive>:20:1:
    No instance for (Show (WriterOptions -> Pandoc -> [Char]))
      arising from a use of `print'
    Possible fix:
      add an instance declaration for
      (Show (WriterOptions -> Pandoc -> [Char]))
    In a stmt of an interactive GHCi command: print it

I expected the corresponding show instance to be imported automatically, but it seems that's not the case. And I must admit I don't have any clue how to define an instance declaration for (Show (WriterOptions -> Pandoc -> [Char]). As a workaround, I've tried to import additional module of the Pandoc library, but still no Show instance available.

Then Should I define this instance by myself ?
If yes, have you any tips to share with me to complete this task.
If I shouldn't what's the issue ?

Thanks in advance for your help.


EDIT

Ok, I guess I saw my missunderstanding :

Doing :

zurgl>>>map (\x-> fst x) P.writers 
["native","json","html","html5","html+lhs","html5+lhs","s5","slidy","slideous","dzslides","docbook","opendocument","latex","latex+lhs","beamer","beamer+lhs","context","texinfo","man","markdown","markdown+lhs","plain","rst","rst+lhs","mediawiki","textile","rtf","org","asciidoc"]

I think it make no sens to try to Show the second stuff in my tuples. It souhld be something like a function then we can't show it.

I guess it should be the problem.

1
What are you trying to achieve ? It's very common there are no Show instances for functions, ie. the same applies to Text.Pandoc.writers . It does not make much sense to convert them to String representation.David Unric
If you answer your own question you're encouraged to write up an answer and accept it, so anyone who finds this question later on can easily see how you solved it.Jeff Burka
@David : At the begin, I'd like to traverse the list of writer in order to have a way to use them dynamically, then I basically started to print it into ghci and it was a very bad idea to process like this, Finally, the only thing I've achieve, it's to show how can i be dizzy something :s.zurgl

1 Answers

2
votes

What I tried to do make no sense as the tuple contain two different type.
The first one being an identifier (of type string) for a specific writer, the second one being the writer itself (then a function). For sure, if I try to print all of them it will fail as there is no Show instance for function.

Then to retrieve the list of available writer in Pandoc (with the aims to call the corresponding function dynamically), we just have to retrieve the list of identifier, as :

zurgl>>>map fst P.writers 
["native","json","html","html5","html+lhs","html5+lhs","s5","slidy","slideous","dzslides","docbook","opendocument","latex","latex+lhs","beamer","beamer+lhs","context","texinfo","man","markdown","markdown+lhs","plain","rst","rst+lhs","mediawiki","textile","rtf","org","asciidoc"]