-
Notifications
You must be signed in to change notification settings - Fork 1
Description
This paper by Li-yao Xia, Dominic Orchard, and Meng Wang
Composing Bidirectional Programs Monadically https://link.springer.com/chapter/10.1007/978-3-030-17184-1_6
conceives of monadic profunctors which specialize monoidal profunctors.
type Monoidal p = (Profunctor p, forall x. Applicative (p x))
type Monadic p = (Profunctor p, forall x. Monad (p x))
For parsers, the extra power in Monad is recognized to be context-sensitivity.
For the grammatical printer/parser types, only Parsor is Monadic, not Printor. But, the paper suggests a version of a printer type which is monadic, which in this library's style, and with a punned name (or not), could be:
newtype Lintor s f a b = Lintor {runLintor :: a -> f (b, s -> s)}
deriving via ReaderT a (WriterT (Endo s) f)
instance Monad f => Monad (Lintor s f a)
We could define context sensitive grammars as
type GrammarM a = forall p. (Grammatical p, Monadic p) => p a a
with generators yielded from Parsor and Lintor. What are nice combinators for Monadic profunctors? Should we export overloaded operators for qualified do notation or do Prelude's work out-of-the box for Monadic grammars? What is an equivalent to regexBNF invariant context free grammars for invariant context sensitive grammars?