In Monads for the semantics of natural language , Chung-Chieh Shan shows how monads can be used to give a good uniform repetition of standard accounts of some types of natural language phenomena (interrogation, focus, intensionality and quantification). It defines two operations of composition, A_Mand A'_Mwhich are useful for this purpose.
The first is simple ap. In poweret monad ap, it is an application without deterministic functions that is useful for handling query semantics; in the readerโs monad, this corresponds to the usual analysis of extensional composition; and etc.
It makes sense. However, the secondary layout operation has a type signature that looks just weird to me:
(<?>) :: (Monad m) => m (m a -> b) -> m a -> m b
(Shan calls it A'_M, but I will name it <?>here.) Definition is what you expect from types; it matches very closely ap:
g <?> x = g >>= \h -> return $ h x
I think that I can understand how this does what it assumes in the context of the article (process interrogative verbs for the survey, serve as an intensional structure, etc.). What he does is not terribly complicated, but itโs a little strange to see him play such a central role here, since this is not the idiom I saw before in Haskell.
Nothing useful appears in Hoogle for m (m a -> b) -> m a -> m bor m (a -> b) -> a -> m b.
Does this know any of the other contexts? Have you ever written this feature?
source
share