kellysmith12.21
2021-2-3 13:27:41

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


soegaard2
2021-2-3 13:35:21

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


mflatt
2021-2-3 13:44:15

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


kellysmith12.21
2021-2-3 13:45:22

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


kellysmith12.21
2021-2-3 13:50:27

@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?


mflatt
2021-2-3 13:55:00

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).


kellysmith12.21
2021-2-3 13:59:28

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?


mflatt
2021-2-3 14:00:38

Yes, I believe that’s correct.


mflatt
2021-2-3 14:01:23

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


kellysmith12.21
2021-2-3 14:04:52

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


kellysmith12.21
2021-2-3 14:14:58

@mflatt Thank-you for the info!


yilin.wei10
2021-2-3 15:44:01

yilin.wei10
2021-2-3 15:45:17

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


ben.knoble
2021-2-3 17:17:21

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.)


ben.knoble
2021-2-3 17:20:47

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.


shu--hung
2021-2-3 17:52:47

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)


shu--hung
2021-2-3 17:53:48

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


shu--hung
2021-2-3 17:55:59

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


ben.knoble
2021-2-3 18:02:40

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


shu--hung
2021-2-3 18:43:16

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
2021-2-3 20:11:28

@yvanromanof has joined the channel


sorawee
2021-2-3 21:10:54

@jbclements ping?


a73cram5ay
2021-2-3 21:46:31

[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!


soegaard2
2021-2-3 21:50:43

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


sorawee
2021-2-3 21:52:08

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


soegaard2
2021-2-3 21:54:09

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


a73cram5ay
2021-2-3 22:02:04

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


a73cram5ay
2021-2-3 22:03:59

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


jbclements
2021-2-3 22:23:50

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?


sorawee
2021-2-3 22:24:59

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


jbclements
2021-2-3 22:25:26

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


sorawee
2021-2-3 22:26:13

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)


sorawee
2021-2-3 22:26:37

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


artemchernyak
2021-2-3 22:35:43

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



a73cram5ay
2021-2-3 23:19:09

Doh, thanks—missed that.


a73cram5ay
2021-2-3 23:20:35

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!


hazel
2021-2-4 01:19:46

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