News for hackers. Stuff that matters.
Re:Annotated implementation of microKanren: an embeddable lo... by nerdponx on Wednesday May 25, 2022 @03:24PM (#31509318)
What do you mean by "pure I/O" in this case? And how does logic programming help with that?

I've seen things like this in the context of "algebraic effects", where instead of performing I/O (and instead of using monadic I/O) you build up what amounts to an execution graph of effectful operations, which is then "interpreted" at runtime. Is that what you're describing?

Re:Annotated implementation of microKanren: an embeddable lo... by rscho on Wednesday May 25, 2022 @03:44PM (#31509570)
No, what I'm describing is the "monadic" behaviour of `phrase_from_file/2` and similar predicates. In conjunction with definite clause grammars, this means that your I/O operations either conform to the provided spec or fail. This is a "hot topic" (if LP topics can really still be "hot") and sees active development in new prolog systems.

Check this out for prolog:

https://youtu.be/Dqpxy4W7fAo

https://www.swi-prolog.org/pldoc/man?section=pio

https://github.com/mthom/scryer-prolog/blob/084fc845902f7b43...

"New" stuff in the MiniKanren world:

https://staff.fnwi.uva.nl/c.u.grelck/nl-fp-talks/kourzanov.p...

https://ifl2014.github.io/submissions/ifl2014_submission_18....

Re:Annotated implementation of microKanren: an embeddable lo... by YeGoblynQueenne on Wednesday May 25, 2022 @07:06PM (#31512017)
(Not the OP) Thanks for the links, because 14 years after I first started coding in Prolog I'm still not sure what Pure I/O is or why it is.

I mean, my intuition is that a file is a stream of bytes and wading through that stream is not going to be "pure" no matter what, just because a byte is not a concept in First Order Logic. But, OK, "pure" Prolog is not the same as FOL anyway, and so I may be convinced otherwise when I have the chance to peruse your links. So thanks again and sorry for any negative vibes emanating from my comment.

Re:Annotated implementation of microKanren: an embeddable lo... by rscho on Wednesday May 25, 2022 @07:29PM (#31512228)
"pure" prolog I/O is every bit as pure as Haskell pure I/O, which is ... not very much and in a hand-wavy sort of way. My understanding is that it basically means "either it corresponds to the spec, or it fails". At first, it seems trivial and a strange point of pride to have. Until you realize that most languages actually don't have anything built-in to do that, and must resort to some sort of parser. At which point, the data is already past your I/O gateway and may lead to unpredictable effects in your program. This is not an academic opinion, just my 2c.
Re:Annotated implementation of microKanren: an embeddable lo... by YeGoblynQueenne on Thursday May 26, 2022 @06:04AM (#31516538)
Thanks for taking the time to reply! I appreciate your 2c.

I guess my confusion about pure I/O stems from the documentation of phrase_from_file/2 in SWI-Prolog. The documentation says the predicate is for pure I/O and how it was implemented, and by whom, but it doesn't say what pure I/O is, and why it is needed. I guess the information is somewhere in one (or more) of the canonical Prolog textbooks, which I've only read several years ago (though multiple times over, each).

I have to confess also I'm not much of a purist. My Prolog code looks like bog standard imperative code where I feel it doesn't really matter (e.g. I don't have any prejudice about setof/3 or maplist/2 over findall/3), and I guess file I/O is one of those cases.

Anyway, thanks again, for your links and explanation. I owe you a quantum of knowledge :)