Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is legal Literate Haskell? Formal Syntax somewhere?

Someone had a great idea of combining Literate Haskell and Markdown. Made sense to me, so I wanted to try it. But there is something Haskell doesn't like about the Markdown '#' header syntax:

Hello World

> main = putStrLn "hello, world"

works...

$ runhaskell hello_world.lhs 
hello, world

While...

# Hello World #

> main = putStrLn "hello, world"

doesn't...

$ runhaskell hello_world.lhs
hello_world.lhs:1:3: lexical error at character 'H'

Is there there a definition of what is legal? The Haskell syntax only mentions Literate Haskell by example, and nothing to imply the Markdown syntax is invalid.

like image 923
Anm Avatar asked Apr 01 '11 03:04

Anm


2 Answers

A '#' in the first column causes problems with GHCi, even with blank lines before and after code blocks. If you are using Pandoc, you can work around this problem by using underlining for headings.

Hello World
-----------

>  main = putStrLn "hello, world"

This is a known problem: http://hackage.haskell.org/trac/ghc/ticket/4836

like image 155
Peter Avatar answered Oct 14 '22 05:10

Peter


Read this:

http://www.haskell.org/onlinereport/literate.html

It says that to avoid errors, you need a blank line between comments and code.

like image 39
Ptival Avatar answered Oct 14 '22 06:10

Ptival