Fork me on GitHub
#missionary
<
2021-12-06
>
leonoel10:12:54

regarding the attempt/absolve pattern, this is where it comes from https://youtu.be/CIPGZzbPpeg?t=787

leonoel10:12:57

except in missionary disjunction is implemented with thunks

Ben Sless10:12:54

This is cool, compare

(defn absolver [s f]
  (fn [t] (try (s (t)) (catch Throwable e (f e)))))
And From uKanren
(define (disj g1 g2) (lambda (s/c) (mplus (g1 s/c) (g2 s/c))))

Ben Sless10:12:52

Where mplus is

(define (mplus $1 $2)
  (cond
    ((null? $1) $2)
    ((procedure? $1) (lambda () (mplus $2 ($1))))
    (else (cons (car $1) (mplus (cdr $1) $2)))))

Ben Sless10:12:18

The final case is a stream, the second case is a thunk

leonoel17:12:51

I'll have to re-read that paper

Ben Sless17:12:07

It's fun to read, concise and yet builds everything up gradually without heading off into the deep theory which underlies the correctness in the implementation

Ben Sless10:12:07

Regarding Clojure core interfaces which I brought up on Saturday, the idea was that if Flow implemented IReduce it wouldn't even have to block. To begin with you could just return what Reduce does now. The idea is to support the interface

leonoel10:12:37

I don't understand how it is possible to get clojure.core/reduce working on flows without blocking the thread at some point

Ben Sless10:12:57

Just like https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L634 It doesn't have to be a function , it could be defined by a channel

Ben Sless10:12:27

Then a channel is reducible but doesn't block, returns a go block

Ben Sless10:12:14

I don't see anything about the semantics of reduce which require it to be blocking in the calling thread

leonoel11:12:18

when I use clojure.core/reduce , I expect to get a value, not a lifted value

leonoel11:12:34

clojure.core.async/reduce is lifted many -> lifted one, like m/reduce

Ben Sless11:12:02

I know, I'm wondering if that's correct

Ben Sless11:12:18

Why shouldn't reduce preserve context?

leonoel11:12:33

so what you're suggesting is if you pass a flow to clojure.core/reduce , it does what m/reduce does and returns a task ?

leonoel11:12:14

ok I understand

Ben Sless11:12:12

my rationale is as follows - we can say map is a private case of reduce? But map is defined for every functor and its definition is that it keeps context

Ben Sless11:12:25

Why shouldn't that context preservation be expanded?

leonoel11:12:13

map is not fmap

Ben Sless11:12:23

That's a historical mistake

Ben Sless11:12:41

in Haskell's implementation

leonoel11:12:53

in clojure too

Ben Sless11:12:08

Yes, but because Clojure is dynamic it was easy to add a transducer arity and call it a day

Ben Sless11:12:49

I remember I searched some time ago for a definition of reduce in terms which don't require lists, didn't find anything satisfactory

Ben Sless11:12:00

The "convenient" reason to do this is it reduces the surface area of missionary