polysemy-research / polysemy-zoo

:monkey::panda_face: Experimental, user-contributed effects and interpreters for polysemy
BSD 3-Clause "New" or "Revised" License
70 stars 20 forks source link

Changes to accommodate v1.2 #46

Closed KingoftheHomeless closed 5 years ago

KingoftheHomeless commented 5 years ago

This can be merged once we decide to release polysemy v1.2

isovector commented 5 years ago

:heart: it, thanks! I'll look into cutting a new release tomorrow.

isovector commented 5 years ago

Are we good to land 1.2? I'll do it today

KingoftheHomeless commented 5 years ago

We're ready.

I'm planning on a Tagged effect, but it probably belongs in the zoo.

KingoftheHomeless commented 5 years ago

Or hell, Tagged's honestly already ready. This is its components:

newtype Tagged k e m a where
  Tagged :: forall k e m a. e m a -> Tagged k e m a
tag :: forall k e r a
     . Member (Tagged k e) r
    => Sem (e ': r) a
    -> Sem r a
untag :: forall k e r a
       . Sem (Tagged k e ': r) a
      -> Sem (e ': r) a
retag :: forall k1 k2 e r a
       . Member (Tagged k2 e) r
      => Sem (Tagged k1 e ': r) a
      -> Sem r a

Do you think it should be part of polysemy?

Example of use:

taggedLocal :: forall k i r a
             . Member (Tagged k (Reader i)) r
            => (i -> i)
            -> Sem r a
            -> Sem r a
taggedLocal f m =
  tag @k @(Reader i) $ local @i f (raise m)
KingoftheHomeless commented 5 years ago

Should have said that to start with.

Well, in any case, my opinion is that it both can and should wait.

isovector commented 5 years ago

Ahh, sorry! I'm happy to push out a 1.2.1.0 sooner than later if we want to get this in.

KingoftheHomeless commented 5 years ago

The thorny thing about Tagged is the question if we should create predefined tagged- variants (like taggedLocal) for everything. That's a hairy enough question for me not to put it in right now.