- Friday, 18th October, 11:55 pm
- 30% of your final mark for the unit
- SWOTVAC + Week 13
- Students will create a parser for a subset of the Markdown specification using functional programming techniques in Haskell.
- Demonstrate understanding of functional programming, including documentation of design decisions.
- Submit a zipped file named
<studentNo>_<name>.zip
which extracts to a folder named<studentNo>_<name>
.- Must contain all code, report (named
<studentNo>_<name>.pdf
). - No additional Haskell libraries (except for testing).
- Run
stack clean --full
before zipping. - Don't submit
node_modules
or.git
folder. - Ensure code executes properly.
- Must contain all code, report (named
- Marking process:
- Extract zip.
- Copy submission folder contents.
- Execute
stack build
,stack test
,stack exec main/npm run dev
for front end.
- Penalised at 5% per calendar day, rounded up.
- After seven days, receive zero marks and no feedback.
- Introduction
- Goals / Learning Outcomes
- Scope of assignment
- Exercises (24 marks)
- Report (2 marks)
- Code Quality (4 marks)
- Marking breakdown
- Correctness
- Changelog
- Parse up to and including code blocks (with high code quality and good report) for a passing grade.
- Higher mark requires parsing more difficult data structures and modifying the HTML page.
- Develop a transpiler to convert Markdown to HTML in Haskell.
- Web page sends Markdown to Haskell backend server, which converts and returns HTML.
- Use materials from previous weeks, reference external sources.
- Assignment split into parsing, pretty printing, and extras. Recommend doing Part A and B in tandem.
- Parse based on Markdown specification with restrictions.
- Use functional programming and parsing effectively.
- Understand and use key functional programming principles.
- Apply Haskell and FP techniques to parse Markdown.
- Parse expression into data types and convert to HTML string.
- Not required to render Markdown or HTML strings.
- Parse markdown string into Algebraic Data Type (ADT).
- Define own ADT and functions to parse requirements.
- ADT should have enough info for HTML conversion.
- Add
deriving Show
to ADT and custom types. - Export
markdownParser :: Parser ADT
andconvertADTHTML :: ADT -> String
. - Example scripts:
- Run
stack test
to parse Markdown and save output. - Use
npm run dev
withstack run main
to test in real-time.
- Run
- Italic Text:
_italics_
- Bold Text:
**bold**
- Strikethrough:
~~strikethrough~~
- Link:
[link text](URL)
- Inline Code:
`code`
- Footnotes:
[^ℤ+]
(e.g.,[^1]
,[^2]
)- No whitespace inside
[
and]
. - No nested modifiers.
- Text inside modifiers can have whitespace (excluding new lines).
- No whitespace inside

- Alt Text, URL, Caption Text don't consider text modifiers.
- At least one non-newline whitespace between URL and caption text.
- No spaces after
!
and before[
.
[^2-^]: text
(ignore leading whitespace before text).
- Any text not following other types, may contain modifiers.
# Heading 1
to###### Heading 6
- Alternative syntax:
Heading 1
followed by======
for level 1,Heading 2
followed by------
for level 2. - Headings may have modifiers.
- Start with
>
at the beginning of a line. - Ignore leading whitespace after
>
and before text. - Text inside can have modifiers.
- No nested block quotes.
- Starts and ends with three backticks (```), with optional language identifier.
- Code block should not consider text modifiers.
- Starts with number 1, followed by
.
and at least one whitespace. - Can have sublists with 4 spaces before each item.
- Items may contain text modifiers.
- Don't handle unordered lists.
- Use pipes
|
to separate columns and dashes-
to separate header and content rows. - Compulsory beginning and ending pipes.
- Each row must have the same amount of columns.
- Cells may contain text with modifiers, ignore leading and trailing whitespace.
- Convert ADT to HTML representation.
- Indent HTML with 4 spaces to reflect tree structure.
- HTML must be a self-contained webpage with appropriate tags.
- Italics:
<em>italics</em>
- Bold:
<strong>bold</strong>
- Strikethrough:
<del>strikethrough</del>
- Link:
<a href="URL">link text</a>
- Inline Code:
<code>code</code>
- Footnotes:
<sup><a id="fn1ref" href="#fn1">1</a></sup>
<img src="URL" alt="Alt Text" title="Caption Text">
<p id="fn1">My reference.</p>
<p>Text</p>
<h1>Heading 1</h1>
to<h6>Heading 6
<blockquote><p>Text</p></blockquote>
<pre><code class="language-haskell">Code</code></pre>
<ol><li>Item</li></ol>
<table><tr><th>Header</th><td>Data</td></tr></table>
- Add a button to save converted HTML using Haskell (saved with ISO 8601 formatted time).
- Add an input box to change the page title.
- Involves changes to HTML page and TypeScript code.
- Implement interesting, impressive, or "show-off" features related to Haskell, FP, or parsing.
- Suggestions:
- Markdown validation (e.g., enforce table column width).
- Correct BNF for parsing in report (worth 2 marks).
- Further extensions to webpage using RxJS.
- Parse nested text modifiers.
- Parse further Markdown parts.
- Comprehensive test cases.
- Max 600 words.
- Summarise code intention, highlight interesting parts and difficulties.
- Include:
- Design of code (data structures, approach, structure, architecture choices).
- Parsing (usage of parser combinators, choices, construction using typeclasses).
- Functional Programming (small functions, composition, declarative style).
- Haskell Language Features Used (typeclasses, custom types, higher order functions, composition).
- Description of Extensions (if applicable).
- Readable and functional code, comment when necessary.
- Keep lines < 80 characters.
- Comment non-trivial functions and unclear code sections.
- Functions should be small, modular, use built-in functions.
- Reuse previous functions, avoid repeating work.
- Well-structured ADT.
- Main marking criteria for each parsing and pretty printing exercise: correctness (50%) and FP style (50%).
- Provided with sample input and tests, encouraged to add own for edge cases.
- Series of tests to determine marks based on passed tests.
- Relates to code alignment with unit content and functional programming.
- Apply course concepts effectively.
- Avoid imperative style coding.
- Added note about non-empty text modifiers.
- Added note about BNF simplification for non-context-free parsers.
- Removed requirement to parse nested text modifiers (made it an extension).
- Fixed issue in scaffold (frontend HTML output).
- Changed "Abstract Data Type" to "Algebraic Data Type".
- Clarified image URL and caption text rules.
$ stack test
This will generate the HTML files using the sample input markdown files, by running your code for each exercise.
All example markdown files are stored within examples/input
and the output of your parser will be saved in examples/output
.
In the Haskell folder run:
$ stack run
In a separate terminal, in the javascript folder run:
$ npm i
$ npm run dev
You can type markdown in to the LHS of the webpage and inspect the converted HTML.