My question is about the Applicative and Monad type classes on the one hand, and the context-free and context-sensitive grammar levels of the Chomsky hierarchy on the other.
I've heard that there's a correspondence between the type classes and the grammar levels. How exact is this correspondence?
That is, can all context-free grammars be parsed using nothing stronger than Applicative combinators, and do are all grammars that can be parsed using nothing stronger than Applicative combinators context-free? In other words, does the Applicative type class exactly correspond to context-free grammars?
And the same question, except with 'context-free' substituted by 'context-sensitive' and Applicative by Monad.
Bounty clarification: do type class(es) correspond to grammar levels? For example, is there a set of type classes which provide all the operations required for expression regular languages and nothing more?
The motivation for the question is that I was working on a parser, and wanted to determine which grammar level my implementation was at based on the combinators I used. Is this possible?
Chomsky Hierarchy represents the class of languages that are accepted by the different machine. The category of language in Chomsky's Hierarchy is as given below: Type 0 known as Unrestricted Grammar. Type 1 known as Context Sensitive Grammar.
In formal language theory, computer science and linguistics, the Chomsky hierarchy (also referred to as the Chomsky–Schützenberger hierarchy) is a containment hierarchy of classes of formal grammars. This hierarchy of grammars was described by Noam Chomsky in 1956.
I don't think anyone has shown this formally. The reason is that neither applicative nor monad is able to parse much of anything on its own. Rather, you also need
that said, with (non deterministic) choice and (arbitrary) recursion, Applicative parsers essentially exactly match the interface for BNF (and so can parse all CFLs), while monads can provide arbitrary context sensitive operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With