Coding in Haskell | Writing and debugging megaparsec parsers for grep

Ғылым және технология

Try building your own smth using CodeCrafters, my affiliate link: app.codecrafters.io/join?via=...
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
Subscribe to Impure Pics: bit.ly/impure-youtube
How to think like a functional programmer
🎓 impurepics.thinkific.com/cour...
More Impure Pics
🐣 / impurepics
📦 impurepics.com
👕 merch.impurepics.com
Functional Alphabet book
📗 Softcover: bit.ly/fp-abc-soft-cover
📘 Hardcover: bit.ly/fp-abc-hard-cover
Watch more Impure Pics
• Debunking Haskell Myth...
About Impure Pics
FP Advocat. Distilling functional programming for the good of all
Get in touch: zelenya.com
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

Пікірлер: 7

  • @Axman6
    @Axman6Ай бұрын

    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 ❤

  • @FredMaterias
    @FredMateriasАй бұрын

    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.

  • @user-pe7gf9rv4m
    @user-pe7gf9rv4mАй бұрын

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

  • @MikkoRantalainen
    @MikkoRantalainenАй бұрын

    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.

  • @Axman6

    @Axman6

    Ай бұрын

    As someone who’s been programming Haskell for about 15 years, and a lot of that time using Fira Code, I didn’t even notice 😅 This is a good tip though, for anyone trying to make programming understandable.

  • @GavinFreeborn
    @GavinFreebornАй бұрын

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

  • @impurepics

    @impurepics

    Ай бұрын

    The slides with text? Either google slides or apple keynotes. With “animations” via procreate

Келесі