
On 11/2/10 7:09 AM, Sebastian Fischer wrote:
On Nov 2, 2010, at 9:27 AM, Gregory Crosswhite wrote:
Which does raise the question: when is it better to use a logic programming language instead of the list monad?
It is more cumbersome to model logic variables and unification in a pure functional language than having them provided natively. If you need unification or constraint solving then a language with built-in logic variables has an advantage.
Indeed. If your program requires unification or constraint solving then logic programming or constraint programming[1] is the way to go. However, if all you need is backtracking or search, then while logic/constraint languages may be helpful because they have optimized search combinators built in, but they don't offer anything particularly interesting over doing search in functional programming. Though I would suggest you look at the LogicT library instead of using actual lists... Also, you may be interested in reading the LogicT paper[2] or this paper[3] about search combinators in Haskell. Both offer a number of optimizations you should be aware of. [1] Or constraint-logic programming a la ECLiPSe: http://eclipseclp.org/ [2] http://okmij.org/ftp/papers/LogicT.pdf [3] http://web.cecs.pdx.edu/~apt/jfp01.ps -- Live well, ~wren