Replies: 1 comment
-
|
Two things to look at: named effects + scoped effects https://github.com/koka-lang/koka/blob/dev/samples/handlers/named/file-scoped.kk https://github.com/koka-lang/koka/blob/dev/samples/handlers/named/heap.kk A paper discussing this is: https://www.microsoft.com/en-us/research/publication/first-class-named-effect-handlers/ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose I have a simple file system effect:
To be able to use this safely (i.e. without bugs) I need to make sure a
handleobtained from afile-systemhandler needs to be used with the same handler.(To keep things simple let's assume that all file system handler use the same handle type, maybe an integer.)
For example, if I have an in-memory file system implementation of this effect, and do
open-filewith a handler and useread-filewith another handler, I'll get an error or read a wrong file.This problem is not specific to Koka, and I'm not seeing anyone trying to tackle this problem (or maybe they don't publish about it?). I'm wondering if you considered this issue at all?
The higher ranked types trick (used in Haskell's ST and
managed) is one way but it's also quite limiting: the entire effectful code needs to be lexically enclosed with the effect handler, so e.g. you can't store thehandlein a map and use it elsewhere.This could be solved at the user level by adding a unique handler id to
handleand check that thehandle's id matches the handler's id inread-file. Maybe a combination of this (when the values escape) and the higher-ranked types trick (when the values don't escape) is good enough? I'm wondering if you've experimented with this kind of thing at all and what your experience was.Beta Was this translation helpful? Give feedback.
All reactions