On Wed, Oct 16, 2013 at 10:33 PM, Thiago Negri <evohunz@gmail.com> wrote:
Okay, I solved the exact test case the paper proposed.
Awesome!
Now I've hit another problem:
> loop_bufid :: SP a a
> loop_bufid = loop (Get (\a -> Get (\b -> Put a (Put b id))))
Even better! I was kinda worried that you weren't going to get to this stage.
So here's what I see:
* this is a problem harder than it look (duh!)
* that you've got this far is super-impressive: search "instance ArrowLoop SP" to see what others have attempted
And you know what? I don't think there's a solution, not in this generality at least.
Let's break up the problem a bit:
(A) the fifo/buffer/queue suggested by the problem needs to have Time-Travelling Superpowers. Even when it's empty, you can query values (supplied from the future) to keep your computation running. Oh, and obviously, it's gotta be infinite, i.e. no fixed capacity.
(B) some SPs simply won't evaluate to anything meaningful (relative to standard metaphysics) under loop, e.g.
existentialism :: SP (String, Bool) (String, Bool)
existentialism = let r = Get( \(_,x) -> Put( if x then "Heaven" else "Hell", not x ) r ) in r
Either of (A) or (B) is worthy of pursuit.
(A) is very haskell-y because one can't even imagine these things using other languages, all of which fall under strict semantics. Good evidence of Sapir-Whorf, don't you think?
For (B), I'd think about restricting the space of SPs to get rid of some of the junk. E.g. allow SPs such as Get...Put...Get...Get...Get..., but not those that whose constructors VARY according to the Get binding, essentially the Applicatives vs Monads distinction.
(B), whose mantra is Make the Meaningless/Buggy Un-Codeable, is immediately useful in all PLs, but Haskell's type system gives the programmer uniquely powerful leverage in that direction.