r/purescript • u/natefaubion • Apr 17 '17
purescript-run: an extensible-effects implementation
https://github.com/natefaubion/purescript-run
13
Upvotes
r/purescript • u/natefaubion • Apr 17 '17
View all comments
Show parent comment
2
u/natefaubion Aug 10 '17
I don't think it was ever a goal of the core
Effto be algebraic. The problem with that is the labels mean whatever you want them to mean. They are essentially just documentation. I personally think Eff label elimination (in the presence of open effects) is unsound, and largely useless, if not dangerous. For example, if I introduce an effectTIMERwithwhich takes an
Effto run on the native scheduler, and theEffI give it propagatesEXCEPTION, then the returnEffforsetTimeoutwill also have thatEXCEPTION. The elimination rulecatchExceptionremoves the label, but there are implicit assumptions (which aren't part of it's type) that this only works in a synchronous environment, which is not composable with mysetTimeoutfunction. If I usecatchException, then the type system will tell me there are no exceptions, but this untrue. I would have to introduce a special variant of the function that prohibitsEXCEPTIONlabels withRowLacks, potentially, but this is no longer extensible.purescript-rundoesn't have that problem because it requires runtime interpretation of an entire computation to eliminate some effect, which has an obvious cost compared to the documentation approach.I hope to see the default
Effreplaced by an unindexedIOtype. And then I thinkEffcan be built with a closed set of common low-level effects, which would mean you can provide rules for how these actions interact with each other in a way that doesn't have annoying edge cases.