Coding in Haskell | Writing and debugging megaparsec parsers for grep

preview_player
Показать описание

In this tutorial, we build grep from "scratch" by following a CodeCrafters challenge: we work with megaparsec, debug parsers, and rewrite the same things multiple times.

#fp #functionalprogramming #haskell

*How to think like a functional programmer*

*More Impure Pics*

*Functional Alphabet book*

*Watch more Impure Pics*

*About Impure Pics*
FP Advocat. Distilling functional programming for the good of all

0:00:00 Intro
0:00:28 Hurdle 1. Stack and GHC version
0:00:51 Match literal char, digit, alphanumeric
0:03:12 Splitting pattern, parsing, and matching
0:06:42 1st (regex) parser. Introducing megaparsec
0:15:03 2nd (matcher) parser. Parsing many characters. Some debugging
0:26:07 Start and End of string anchors. 1st attempt
0:33:48 Start and End of string anchors. 2nd attempt
0:39:13 Quantifiers. 1st attempt
0:45:06 Wildcard. Realizing that quantifiers don't work
0:46:17 Quantifiers. Debugging and refactoring
0:51:37 Quantifiers. Adding State
1:03:56 More debugging
1:10:26 Alternations
1:13:58 Recap
Рекомендации по теме
Комментарии
Автор

I really enjoyed watching this, it felt far more realistic than many dev videos where people don’t make mistakes. Getting quantifiers working is *hard*, and I’m sure that I would’ve gotten just as lost.

In my last job, I had to implement a parser and evaluator for the reflexes found in XML schema. Luckily the Haskell wiki has the page “Regular expressions for XML Schema”, which has the most beautiful implementations of regexes you’ll ever see. I’d love to see you go back through this exercise after reading that (and discussing the page too).

This is your first video I’ve watched but I’m loving it - instant subscribe ❤

Axman
Автор

Thank you 100%; this was a very informative and concrete video, its been hard to find real understandable (but not trivial "calculatory") haskell materials.

pegfrvm
Автор

Hey, just a tip I stumbled upon a while back, instead of changing the haskell version of your project just compile hls using ghcup, you can do that using "ghcup compile hls -g master --ghc ${your-target-version}" and it is much better than changing the version and probably breaking something down the line.

FredMaterias
Автор

Just curious, what program do you use for ceeating your usual slideshows?

GavinFreeborn
Автор

Great video! I think it would be better to use more readable font in the editor such as Source Code Pro (free open source font) because your current font uses kerning and glymph substitution tricks to make it harder to understand what you're actually typing.

MikkoRantalainen
Автор

I liked codecrafters, but it is quite expensive

danconcep
welcome to shbcf.ru