Skip to content

Nested mixed effects? #446

Open
Open
@eyeinsky

Description

Is something like the following possible in polysemy where given the effects

data E1 :: Effect where
  E1_unit :: E1 m ()
  E1_rec :: something.. a -> E1 m a

makeSem ''E1

data E2 :: Effect where
  E2_unit :: E2 m ()
  E2_rec :: something.. a -> E2 m a

makeSem ''E2

one could write something like this:

main = do
  e1_rec $ do
    e1_unit
    e2_unit
    e2_rec $ do
      e1_unit
      e2_unit
  e1_rec $ do
    e1_unit
    e2_unit
  ..

I.e I arbitrarily mix different effects under both effects' _rec variants and the effect stack is same on each "level".

My actual use case is that I have DSLs for generating css and javascript both of which have their separate effects/GADTs and interpreters, and am wondering if I could re-use them without writing a sum GADT.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions