News for hackers. Stuff that matters.
Re:Parsing with Haskell by sondr3 on Thursday July 07, 2022 @07:50AM (#32012793)
It doesn't need any extensions to work, the only reason `OverloadedStrings` is enabled in the tutorial is because the parser uses `Text` over `String` to parse the input.
Re:Parsing with Haskell by johnday on Thursday July 07, 2022 @08:47AM (#32013353)
In fact, I would recommend against enabling OverloadedStrings while writing parsers, since it can be confusing. Some bright spark added an IsString instance for IsString a => Parser a, meaning that "Hello" is a parser for the string "Hello". It also means that `many "Hello"` will parse "HelloHelloHello", which is kinda cool but confusing for a beginner.
Re:Parsing with Haskell by massysett on Thursday July 07, 2022 @09:10AM (#32013625)
From Text.Megaparsec:

    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE Safe #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TypeFamilies #-}
    {-# LANGUAGE UndecidableInstances #-}
And you do have to understand TypeFamilies to use Megaparsec.
Re:Parsing with Haskell by nimih on Thursday July 07, 2022 @02:09PM (#32017350)
> And you do have to understand TypeFamilies to use Megaparsec.

This is only the case if you're using custom input streams, right? Writing a parser that just operates on ByteString/Text seems like a pretty gentle/reasonable introduction to this style of parsing and doesn't require any understanding of TypeFamilies as far as I can tell (I certainly didn't understand TypeFamilies when I learned to use megaparsec).

Re:Parsing with Haskell by massysett on Thursday July 07, 2022 @08:52PM (#32021684)
The types of many basic and essential functions, including ‘satisfy’ and ‘token’, use type families with associated types, but yes, it is possible to use megaparsec without actually understanding the types.
Re:Parsing with Haskell by simonmic on Monday July 11, 2022 @01:17AM (#32052499)
No you don't.