Skip to content

"Shadowing" Handles #33

@maralorn

Description

@maralorn

This is not a pressing matter, but I am bringing it up in the interest of keeping the discussion from ghc-proposals/ghc-proposals#621 (comment) going.

In playing around with bluefin I noticed that it is hard to express that an effect must not be allowed at some place, while other effects can. I think this came up for me while writing a terminal UI. Imagine I have two effects ReadWrite and NCursesUI. The handler of NCursesUI needs the ReadWrite effect

runNCursesUI :: (e :> es) => ReadWrite e -> (forall eui. NCursesUI eui -> Eff (es :& eui) r) -> Eff es r

I find it hard get the effect tags right so that

a) arbitrary effects can be passed through to the inner action.
b) the inner action cannot use the ReadWrite handle directly (because that would most likely screw the UI output)

I realize that this is a strong requirement and a) more or less makes b) impossible already on a theoretical level. But I thought that maybe having the ReadWrite handle be linear could make sure that it is only used by exactly one handler.

Tangentially: I tried expressing in some way, that runNCursesUI plucks e out of es:

runNCursesUI :: ReadWrite e -> (forall eui. NCursesUI eui -> Eff (es :& eui) r) -> Eff (e :& es) r

but this does not prevent the caller from putting e into es on the outside anyway and it also makes this handler inconvenient to use because it suddenly restricts the effect order in the tag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions