Skip to content
0:00 / 0:00

#parsec#parsercombinators#applicative

Parsing Stuff in Haskell

London Haskell

1.5K subscribers • 7 videos on Hallway

YouTube
  • Recommended by 4 people: 4 in engineering communities.
  • Presented by Ben Clifford

Intermediate. Assumes working knowledge.

27K views13 years ago4 recommendations

Programming languagesComputer scienceHaskellCompilers and interpretersFunctional programming

Ben Clifford explains how to use Parsec parser combinators in Haskell, comparing applicative and monadic parsing styles.

London Haskell user group, 24rd January 2013. A talk by Ben Clifford on Parsec parser combinators.

Why it's here

4 people recommend this

What people say. Highly recommended for helping developers grasp parser combinators and understand the difference between applicative and monadic parsing.

u/haskellgr8in r/haskell • Recommends

On “I'm not familiar with package managers of other languages. What other languages have a mechanism like stack resolvers, for reproducible builds?”

By the way, if you're this guy, thank you. Really helped me grasp parsers a few months ago.

u/tWooliein r/haskell • Recommends

On “Tutorial for building a compiler in Haskell?”

Well, GHC is written in Haskell... so I guess that's your canonical way of writing a compiler in Haskell. You could also look at the source for elm's compiler for ideas. Some great libraries for writing a compiler: * `parsec` is a library for writing parsers in a terse and straightforward way. `attoparsec` is a specialised, high-performance variant. (link to this video, tutorial) * `bound` is a library for performing capture-avoiding substitution through a simple `Scope` monad. (tutorial, typechecker) * `uniplate` is a library for performing transformations on recursive structures like ASTs. It makes writing optimisations fun an easy! (tutorial)

u/MyFuncin r/haskell • Recommends

On “Having trouble with Write Yourself a Scheme”

I recommend watching the following video (Ben Clifford - London Haskell user group) - link to this video The point on Applicative vs Monadic parsing comes up in this talk. When possible, the applicative style is more efficient, however, the monadic `do` notation is arguably more readable. Using the `ApplicativeDo` language extension, it is possible to get the best of both worlds (using GHC 8) - https://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo I also suggest considering another parsing library. There are a few popular parsing libraries including Parsec, Trifecta, Megaparsec and Attoparsec. From what I understand, Attoparsec is best when speed is required but comes at the expense of bad error messag…

u/mechanical-elephantin r/haskell • Recommends

On “I have no formal training in CS, I'm learning Python with I want something more rigorous. Is haskell for me?”

Actually just saw this comment. Realistically it took about a month to be comfortable. This was done by just reading stuff and writing code. Getting feedback from real humans can be a major benefit. If I could go back and give myself some advice on learning haskell, it would be this: Don't try to make it too complicated. You just need to focus on two things, writing simple functions that do a specific thing and writing basic types (records + algebraic datatypes go *very* far). Don't write your own typeclasses. 98% of the time you don't need a custom typeclass. To become productive, you will need to use typeclasses, just don't write a new one. You will need to know Functor, Applicat…