[personal profile] kpreid

Has anything been done in logic programming (especially in languages not too far from the classic Prolog) which is analogous to monads and the IO monad in Haskell; that is, providing a means of performing IO or other side-effects which does not have the programmer depend on the evaluation/search order of the language?

In other words, what is to Prolog as Haskell is to ML?

Curry?

Date: 2010-10-06 12:46 (UTC)
From: (Anonymous)
How about Curry? it looks like Haskell. Has the IO Monad, however it is a logical programming language.

http://www-ps.informatik.uni-kiel.de/currywiki/

Mercury

Date: 2010-10-06 12:47 (UTC)
From: (Anonymous)
http://www.mercury.csse.unimelb.edu.au/

Re: Mercury

Date: 2010-10-06 15:14 (UTC)
From: [identity profile] virkony.livejournal.com
Agree. Actually Mercury have no monads which can be combined etc. It works more like direct passing of RealWorldState through arguments (Unique Input and Destructive Output). But it allows it only for det and cc_multi (commited choice) modes as I remember. So it maintains purity and allows much more nice features (like custom modes and instances), but it still need improvements.

(no subject)

Date: 2010-10-06 18:32 (UTC)
From: (Anonymous)
Prolog has DCG notation, which is completely analogous to "do"-syntax with Haskell's monads: It allows you to transparently thread an implicit state through. It is not only useful for parsers, but for general stateful computation with its metamorphosis extension.

(no subject)

Date: 2010-10-06 21:25 (UTC)
From: [identity profile] darius.livejournal.com
I don't know of anything that enforces things like monads do.

Ask MarkM about Concurrent Prolog. IIRC I/O was handled as incrementally-filled-in lists, analogous to pre-monad Haskell using lazy lists, but using logic variables. Oz would be a more modern example.

Mercury's approach is more like Clean's uniqueness types than monads, IIRC.