Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!cs.utexas.edu!uunet!newsflash.concordia.ca!CC.UMontreal.CA!IRO.UMontreal.CA!tarau
From: tarau@IRO.UMontreal.CA (Paul Tarau)
Subject: Re: A research problem for y'all (or: yet another monad article)
Message-ID: <D34Dtt.L2@IRO.UMontreal.CA>
Sender: news@IRO.UMontreal.CA
Organization: Universite de Montreal, Canada
References: <3g92ar$sbb@hitchcock.dfki.uni-sb.de>
Date: Sat, 28 Jan 1995 14:34:40 GMT
Lines: 70

In article <3g92ar$sbb@hitchcock.dfki.uni-sb.de> vanroy@dfki.uni-sb.de (Peter Van Roy) writes:
>Here's a research problem that I'd like to work on, but that I don't have time
>for right now.  I'm throwing it to you wolves in the hope that someone can chew
>on it and reap all the fame and glory and give us a few crumbs of enlightenment.
>

The following paper, available by ftp from

   clement.info.umoncton.ca

in directory

    pub/OtherPapers/LPwithMonads.ps.gz

does some of this and more :-)

--------------------------------------------------------------------
\title{Logic Programming
with Monads and Comprehensions}

\author{
Yves Bekkers~\thanks{
   Universit\'e de Rennes I and IRISA/INRIA Rennes,
   {\em bekkers@irisa.fr}
}
\and
 Paul Tarau~\thanks{
 D\'epartement d'Informatique,
   Universit\'e de Moncton,
 {\em tarau@info.umoncton.ca}
}
}

We give a logical reconstruction of all-solution predicates in terms of
list comprehensions in $\lambda$Prolog's and we describe a variety of
logic programming constructs in terms of monads and monad morphisms.
Novel monad structures are described for lazy function lists, clause
unfoldings and a monad morphism based embedding of Prolog in
$\lambda$Prolog is given.

{\em Keywords:  computing paradigms, logic programming, monads, list
comprehensions,  all solution predicates, $\lambda$Prolog, higher-order
unification, lazy function lists.}
-----------------------------------------------------------------------
One of the most useful things for real programmers are monad morphisms,
there's one in the paper, allowing an embedding of (untyped) Prolog in (typed)
LambdaProlog.

DCGs, EDCGs and BinProlog 3.0's `invisible grammars' (multiple-stream
DCGs with implicit hidden backtrackable state, instead of the usual
preprocessor based translation) are all instances of monadic
constructs (see the section in BinProlog's UserGuide on `invisible
grammars').

An interesting point we have not yet explored in depth is the link
between monad comprehensions and Prolog's all-solution predicates
and how the latter would benefit from a monadic revamping.

A set of Haskell-like higher-order constructs taking advantage
of Prolog's unique OR-intensive programming-style can be found in
the paper HighOrderOrStyleLP.ps.gz in the same directory.
This paper is however somewhat dangerous as it might convince you
that the only reason to program in Prolog instead of
Haskell is that Prolog _does_ have backtracking :-).

A hot topic sketched in the paper (but left for more theory-hungry
`wolves' :-)) is the `monad of unfoldings' allowing to describe basic
resolution in terms of monadic unit and join.

Paul Tarau
