Hacker News new | ask | show | jobs
by ogogmad 588 days ago
I imagine this could be understood as making use of a monad. Right?

The main problem with generalised regexes is that you can't match them in linear time worst-case. I'm wondering if this is addressed at all by Raku.

2 comments

A "monad" is not really a "thing" you can make use of, because a monad is a type of thing. Think "iterator"; an iterator is not a thing itself, it is a type of thing that things can be.

There is probably a monad you could understand this as being, a specific one, but "monad" itself is not a way to understand it.

And just as you can understand any given Iterator by simply understanding it directly, whatever "monad" you might use to understand this process can be simply understood directly without reference to the "monad" concept.

> I imagine this could be understood as making use of a monad. Right?

Can you clarify what do you mean?

Do expect the concept of "monad" to help explaining Raku grammars?

Yes. Compare it to the List monad or Parsec.
- There is a natural from-to conversion of Functional Parsers (FP) monad (as in Parsec) to Extended Backus-Naur Form (EBNF).

- Similarly, EBNF can be applied to Raku grammars.

- Hence, the representation of Raku grammars into FP monad is doable, at least for certain large enough set of Raku grammars.

  - See the package "FunctionalParsers".