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

Kleisli: local and lmap are the same #624

Closed
ceedubs opened this issue Nov 11, 2015 · 4 comments
Closed

Kleisli: local and lmap are the same #624

ceedubs opened this issue Nov 11, 2015 · 4 comments
Assignees

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Nov 11, 2015

@philwills has pointed out on gitter that local and lmap on Kleisli are essentially the same thing.

def lmap[C](f: C => A): Kleisli[F, C, B] =
  Kleisli(run compose f)

def local[AA](f: AA => A): Kleisli[F, AA, B] =
  Kleisli(f.andThen(run))

We should probably either remove one of them or make one just an alias for the other (and document that it is so).

My personal preference would be to drop one of them. I think that aliases tend to just make it harder on the user, as it just gives them more to learn.

@adelbertc
Copy link
Contributor

I personally prefer local since the only time I've used it is to "widen" some sort of local config/environment into a more global one, but if there is a more fundamental reason for it being called lmap that's fine by me too.

@ceedubs
Copy link
Contributor Author

ceedubs commented Nov 11, 2015

@adelbertc at the risk of telling you something that you already know, lmap comes from Profunctor. Having said that, the name of the Kleisli method doesn't necessarily need to match up with the name of the method in the type class instance. I would imagine we have other examples where there is a more meaningful name that we use for the method on the data structure.

@adelbertc
Copy link
Contributor

Ah, I did not know that :-)

That being said I agree with having a more meaningful name.. in which case I may swing back to having an alias for one of them or just keeping local :P

@ceedubs
Copy link
Contributor Author

ceedubs commented Nov 12, 2015

Just keeping local sounds good to me.

ceedubs added a commit to ceedubs/cats that referenced this issue Nov 14, 2015
It is the same as Kleisli.local.

Fixes typelevel#624.
@ceedubs ceedubs self-assigned this Nov 14, 2015
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

No branches or pull requests

3 participants