
Does anyone have experience with algebraic effects and effect handlers? I’ve a question about how they relate to continuations.

Have you seen Dorai Sitaram’s paper on unwind-protect
?
https://www.cs.utah.edu/docs/techreports/2003/pdf/UUCS-03-023.pdf#page=52

My experience actually using algebraic effects is limited, but I may be able to answer a question about the relationship to continuations, anyway.

@soegaard2 I’ve not seen that paper; thank-you for linking me to it.

@mflatt (hopefully this isn’t too nebulous) I know that algebraic effects and handlers have a deep connection to, and are most directly implemented using, delimited continuations with prompts and marks. What I’m curious about is their relative expressivity. That is, are algebraic effects a convenient layer on top of continuations, or are they a fairly specialized application of continuations?

I believe it depends on the type system associated with algebraic effects. Most uses of algebraic effects (that I’m aware of) have a type system that constrains the use of effect continuations to make them intentionally less expressive than general continuations, such as limiting how far the continuation can escape. Another possible constraint is to avoid multiple uses of captured continuations (i.e., constrain effect continuations to one-shot). Multicore OCaml requires continuations to be used in an exactly-one-shot way, although the type system does not enforce that (i.e., it’s unsafe).

That seems to imply that, assuming a sufficiently liberal type system and no one-shot restriction, then algebraic effects can have power comparable to general continuations. Is that so?

Yes, I believe that’s correct.

Specifically comparable to multi-prompt delimited continuations, I think.

Hm, now I’m curious about how they compare in terms of programmer ergonomics. Unfortunately, that’s much trickier question.

@mflatt Thank-you for the info!

@kellysmith12.21 Have you seen this https://www.schoolofhaskell.com/school/advanced-haskell/the-mother-of-all-monads?

I think there was a separate Oleg jotting somewhere as well, but I can’t find it.

Q about processing a module’s imports: I can get the list of imports with something like (dynamic-require mod #f)
(module->imports mod)
But I want to collect symbol forms of the module, so I’m looking at something like (append-map (λ (v)
(let-values ([(mp base) (module-path-index-split v)]
[(sub) (module-path-index-submodule v)])
(filter identity (list mp base sub))))
(append-map cdr (module->imports mod)))
This seems to mostly give me what I want, although I think the filter
should really change into a cond to decide what to do when certain things are present. (Only, I don’t really understand when mp and base will both be false.)
My question is, let’s say there’s a module like ;; example.rkt
#lang racket
(module sub racket)
(require 'sub)
then I get the following with my code: '(racket
(submod "." sub)
#<module-path-index='lib-grade[8195]>)
This sort of makes sense (ignore the name 'lib-grade
, pretend it’s 'example
I guess); after some digging, I understand that this came from an index like #<module-path-index:(submod "." sub) + 'lib-grade[8195]>
Now, let’s say I want to also get the submodule’s requires. Neither of the following works to dynamically require the module, so I’m a bit lost (module->imports
won’t work until the module is “declared in the current namespace”, which I thought I could do this way): > s
#<module-path-index:(submod "." sub) + 'lib-grade[8195]>
> (module-path-index-resolve s)
#<resolved-module-path:(submod 'lib-grade[8195] sub)>
> (dynamic-require s #f)
; instantiate: unknown module
; module name: (submod 'lib-grade[8195] sub)
; [,bt for context]
> (dynamic-require (module-path-index-resolve s) #f)
; instantiate: unknown module
; module name: (submod 'lib-grade[8195] sub)
; [,bt for context]
This is all just to process all the requires. (I had started work on a pattern-matching version of this that just examines the require
and module
forms, but I’m unsure how to implement relative-in
, among others, so I’m trying to make this work instead.)

Interestingly, when I add a (require "foo.rkt")
to the module, and then run my code, I also get something like #<module-path-index:"foo.rkt" + 'lib-grade[8195]>
, which I can module->imports
on with no problem.

This could be relevant HILLERSTRÖM, LINDLEY and ATKEY Effect Handlers via Generalised Continuations https://www.dhil.net/research/papers/generalised_continuations-jfp-draft.pdf From my vague (and possibly incorrect) impression, they go back and forth between effect handlers and segmented delimited continuations (I’m understanding it like Racket’s continuation restricted to only a single prompt tag + only delimited operations)

I also believe that you can implement reset and shift as a effect handler. But I think it has nothing to do with being algebraic, like most of the effect handler works.
EDIT: Eff example: https://github.com/matijapretnar/eff/blob/master/examples/delimited.eff

does it work if you have something like (module-path-index-join "example.rkt" s)
?

Yes and no; the dynamic-require goes through, but module->imports
gives the same list as for example.rkt :disappointed:

somehow this works: (dynamic-require (module-path-index-join mod s) #f)
(module->imports '(submod "example.rkt" sub))
btw, if you have control over the language (that “racket”) or can shadow the require
forms, require transformers could then be something helpful https://docs.racket-lang.org/reference/stxtrans.html?q=expand-import#%28mod-path._racket%2Frequire-transform%29

@yvanromanof has joined the channel

@jbclements ping?

[Please feel free to redirect this to a specific channel]
I’ve got Pollen up and running and am trying to explore Pollen Component. Using the sample code just below the sentence “The example above becomes the following with Pollen Component:” in [https://docs.racket-lang.org/pollen-component/], I get the cycle in loading error below.
I can’t find any info on the web wrto that error. I’d appreciate any tips or suggestions that you may have. Thanks!

There are some Pollen users here. If they don’t have a solution, plan B is to write the Pollen “mailing list”. https://github.com/mbutterick/pollen-users/issues

It would be helpful for debugging to see your project code, especially pollen.rkt

My hunch is that very few uses the component package - but it’s just a hunch.

This is the pollen.rkt in the sample:
#lang racket
(require pollen-component
racket/dict racket/string racket/format)
(provide (all-defined-out)
(all-from-out racket/dict racket/string racket/format))
(components-output-types #:dynamic html #:static css javascript)
(define-component (link href . elements)
#:html
`(a ((href ,href)) ,@elements)
#:css
"a { color: red; }"
#:javascript
"var links = document.getElementsByTagName('a'); // …")
@soegaard2

I didn’t see any open or closed issues there, so figured I’d try here first :nerd_face:.

I elected not to grab my own commit, I was erring on the side of not breaking things. I may be overly conservative, there, but I’m extremely conservative when it comes to my own commits. I see that part of that is your text as well. Hope that’s okay?

Ah, that’s totally fine! I just want to ensure that this is intentional. Thanks for the response :slightly_smiling_face:

Yep, sorry not to respond sooner, thanks for the bump.

It looks like this is indeed a bug in pollen-component
. It fails its own test (see https://pkgs.racket-lang.org/package/pollen-component)

Moreover, the repo is now read-only, so I think it’s now dead.

It is an archived repo that hasn’t been updated in 3 years. I’m guessing some API changes happened in that time.


Doh, thanks—missed that.

I saw that the Pollen Component repo had no issues, but I didn’t think to look in the Pollen repo—my bad. Thanks for the suggestion!

leandro made an entire youtube video about no longer using racket so I really doubt it will be updated