News for hackers. Stuff that matters.
Re:Parser Combinators in Haskell by CornCobs on Wednesday December 22, 2021 @10:26AM (#29650527)
What are the benefits of these monadic builder interfaces instead of simply pure functions? One can imagine a simple Html type with html tag functions e.g.

`div :: [Attributes] -> [Html] -> Html`

Instead of using do notation to build up multiple children one would simply supply a list of children. Added benefit of using simpler map/filter/filterMap/mapMaybe vs their monadic counterparts

Re:Parser Combinators in Haskell by jaspervdj on Wednesday December 22, 2021 @10:47AM (#29650826)
The builder interface has important performance benefits over working with lists: similar to e.g. concatenating many small Strings vs using StringBuilder in Java.

The builder interface indeed does not need to be monadic, you can simply append things using <> and get the same benefits.

The monadic interface is purely a syntactic enhancement on top of that, to reduce the number of operators you need.

Re:Parser Combinators in Haskell by louthy on Wednesday December 22, 2021 @10:40AM (#29650723)
You can pass contextual state/environment in the monad for trivial data binding