Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX around Lift #161

Merged
merged 11 commits into from
Jul 11, 2019
Merged

UX around Lift #161

merged 11 commits into from
Jul 11, 2019

Conversation

googleson78
Copy link
Member

@googleson78 googleson78 commented Jul 5, 2019

Closes #142

Not sure if I should:

  1. Commit the new .cabal
  2. Bump package version
  3. Add a "since" haddock to runLift

src/Polysemy/Lift/Type.hs Outdated Show resolved Hide resolved
Copy link
Member

@isovector isovector left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for tackling this. Left some comments inline. To answer your questions:

  1. I don't really care about the cabal file or not. It'll get fixed via merging one way or another.
  2. Please don't bump the package version
  3. Add a -- TODO(sandy): @since to the haddocks instead, which I search for before releasing new versions.

src/Polysemy/Lift.hs Outdated Show resolved Hide resolved
Lift (..)

-- * Actions
, lift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traditionally this has been called sendM but admittedly that is a crap name. I'm a little concerned about the overlap with MonadTrans.trans --- but I have to say this is nice. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go this way, let's remove sendM across the codebase and reexport lift from Polysemy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just did this because I was following convention (and was sleepy).

I like lift more, because there is no non-Internal send for sendM to be "based off". (like map -> mapM).

It has the same idea as MonadTrans.lift so I don't think that's an issue. (?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and did the rename, if you want to use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rename! Upon looking at the changes though, I'm already confused by the name. I think overloading lift here is only going to lead to confusion in the library. Can we come up with some other name (possibly also for the type itself?)

Copy link
Member Author

@googleson78 googleson78 Jul 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any particularly bright ideas:

  • Name(d) - because you're giving a "name" (syntax) to a thing that already has an interpretation (inspired by logic, where you do the same when you want to refer to an element of your universe by creating a fresh constant)

  • Concrete/Unambiguous (or some nice sounding synonym) - because you're not leaving anything "open to interpretation" (in the Syntax vs Semantics sense in which the other "native" effects are open to "interpretation")

src/Polysemy/Lift.hs Outdated Show resolved Hide resolved
@isovector
Copy link
Member

isovector commented Jul 7, 2019 via email

@googleson78 googleson78 force-pushed the 142_lift branch 2 times, most recently from e2933ee to c824ce8 Compare July 7, 2019 19:39
, Lift (..)
, sendM
, Embed (..)
, embed

-- * Lifting
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this also need a better section name (?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok! But keen eye!

@googleson78
Copy link
Member Author

Renamed to Embed.

{-# INLINE sendM #-}
-- | Embed a monadic action @m@ in 'Sem'.
--
-- TODO(sandy): @since
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this actually needs a @since, added just in case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing has been around since v0, but I guess it doesn't hurt to be explicit about that! Good catch!

Copy link
Member Author

@googleson78 googleson78 Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking more does it needs a @since for whatever version this will be in, because it's renamed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, you're right! That's what I get for reviewing just before bed.

Copy link
Member

@isovector isovector left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is excellent. A few last renamings and then good to go! Thanks again for this!

, Lift (..)
, sendM
, Embed (..)
, embed

-- * Lifting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok! But keen eye!

-- run a @Embed m1@ effect by transforming it into a @Embed m2@ effect.
--
-- TODO(sandy): @since
runEmbed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with runEmbedded

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same thing that exists in Polysemy.IO? This is admittedly a better place for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the original runLift (now renamed to runEmbed, because the effect is Embed) from #142, which started this pr.

It's not the same thing as Polysemy.IO.runEmbedded.

Personally I'm fine with it being runEmbed (in accordance with the other effects), but we need to rename the second one if this is going to be runEmbedded.

{-# INLINE runIO #-}


------------------------------------------------------------------------------
-- | Given some @'MonadIO' m@, interpret all @'Lift' m@ actions in that monad
-- | Given some @'MonadIO' m@, interpret all @'Embed' m@ actions in that monad
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to runEmbeddedInIO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't see this before commenting above.

{-# INLINE sendM #-}
-- | Embed a monadic action @m@ in 'Sem'.
--
-- TODO(sandy): @since
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thing has been around since v0, but I guess it doesn't hurt to be explicit about that! Good catch!

@googleson78
Copy link
Member Author

Is this ready to go?

@isovector
Copy link
Member

isovector commented Jul 11, 2019 via email

@isovector isovector merged commit 48b6768 into polysemy-research:master Jul 11, 2019
@isovector
Copy link
Member

Excellent work. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX around Lift
2 participants