parsonsmatt / parsonsmatt.github.io

My Github pages website
Other
77 stars 25 forks source link

Flipping arrows in "Plucking In, Plucking Out" #53

Open 0xd34df00d opened 3 years ago

0xd34df00d commented 3 years ago

Hey! First of all, that's a great post, and I definitely like your writing style!

Regarding this bit:

Huh. This is totally useless. I suspect I have performed the flipping of arrows incorrectly. Edward Yang has a really good post on category theory and flipping arrows, so I'll read that and come back to this.

Given catch0 :: start -> handler -> result, the arrows there should've been also flipped, resulting in

cocatch0 
  :: result
  -> handler 
  -> start

or, substituting the flipped versions:

cocatch 
  :: (rest, a)
  -> ((rest, a) -> small)
  -> ((small, rest), a)

I think that makes a tad more sense and is actually very close to what you later derive using monadic and comonadic reasoning (in fact that's equivalent modulo keeping the original rest in the resulting tuple).

Cheers!