Skip to content
0:00 / 0:00

#haskell#parsercombinators#monadicparsing

Functional Parsing - Computerphile

Computerphile

2.6M subscribers • 70 videos on Hallway

YouTube
  • Recommended by 2 people: 1 on Lobsters and 1 in engineering communities.
  • Presented by Graham Hutton, Professor at the University of Nottingham

Beginner. No background in the topic needed.

157K views6 years ago2 recommendations

Programming languagesComputer scienceFunctional programmingCompilers and interpreters

Graham Hutton explains the concepts behind functional and combinator parsing using Haskell.

Functional or Combinator Parsing explained by Professor Graham Hutton. Professor Hutton's Functional Parsing Library: bit.ly/C_FunctParsLib facebook.com/computerphile twitter.com/computer_phile This video was filmed and edited by Sean Riley. Computer Science at the University of Nottingham: bit.ly/nottscomputer Computerphile is a sister project to Brady Haran's Numberphile. More at bradyharan.com

Why it's here

2 people recommend this

What people say. Recommended as a clear and accessible introduction to parser combinators in functional programming.

Moments people linked to

u/JavaSuckin r/haskell • Recommends

Functional or Combinator Parsing explained by Professor Graham Hutton

dbremneron Lobsters • Recommends

Functional Parsing (2020)

u/maanloempiain r/ProgrammingLanguages • Mentions

On “Resources for developing simple parsers?”

There is not a "correct" way to write a parser, really. You just write one. Personally I find that it helps to first formally define a grammar using (E)BNF, and then create a parser based on the grammar with parser combinators. (E)BNF is a common way to describe the grammar of a language, which makes it perfect for both specifying and communicating the inner workings of a language without knowledge of the codebase. This step is in no way necessary, but I highly recommend it. Parser Combinators are, in my opinion, the clearest and easiest way to write a parser, because they map very closely to a BNF representation, which is a standard form for a reason. There are a lot of combinator libr…

u/hanshuttelin r/haskell • Mentions

On “How to write a parser in Haskell?”

Here is a very useful video by Graham Hutton. link to this video

u/Axman6in r/haskell • Mentions

On “Parser Combinators.”

Try link to this video

u/ShakespeareToGoin r/haskell • Mentions

On “I need help with Parsing activities”

Ah yes, I expected something like that. So basically a parser takes a list of inputs (let's say a String which is a list of characters). It than parses the value it is intended for parsing and returns it and the rest of the input. So a parser for integers for example would behave like this: parseInt "123abc" = (123, "abc") Notice how it could not parse the "abc" so it left it just on the other side of the tuple. But why do we put that all in a list? Because of this parseInt "abc123" = [] It could not parse the "abc" in the beginning which means it just returned an empty list instead. Some advanced parsers can also return multiple values, but this should not concern you. Usual…
3View on Reddit

u/pbvasin r/haskell • Mentions

On “Exam in 10 days and still dont understand Monads. How do I survive and actually understand them in time?”

I teach Haskell at university level, I usually explain monads starting from concrete examples before presenting the abstraction. One nice example is writing a basic combinator parser library. You can see Graham Hutton doing this in the following Computerphile video: [video The following steps will depend on what your are expected to learn in you specific course (e.g. define your own instances of Monad class, prove the laws, etc.).

u/anentropicin r/ocaml • Mentions

On “Layout Parsing and Nicely Formatted Error Messages”

this video gives a good introduction to parser combinators: [video I first encountered them when looking for a way to do indentation-sensitive parsing ("layout parsing") since it can't be expressed in context-free grammar. So e.g. the Python parser gets around this by relying on a pre-processing step that converts the indentation to INDENT and DEDENT tokens (a bit like adding curly braces) but parser combinators allow you to parse the content directly. ...at that time I found this blog post showing how to use some of the combinators in Haskell's Megaparsec library that are there to help with indentation-sensitive parsing. Nice to see something similar in OCaml!