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

Profunctor instance for StateT #1067

Closed
ceedubs opened this issue May 27, 2016 · 4 comments
Closed

Profunctor instance for StateT #1067

ceedubs opened this issue May 27, 2016 · 4 comments

Comments

@ceedubs
Copy link
Contributor

ceedubs commented May 27, 2016

@vmarquez pointed out to me that StateT forms a Profunctor

@kailuowang
Copy link
Contributor

I gave it a try and failed, since S appears in both input and output, it looks to me that for S it has to be invariant (you need both S => NewS and NewS => S.
@vikraman or @ceedubs mind give some further instruction?
Here is my attempt

def diMap[C, D](f: C => S)(g: A => D)(implicit F: Functor[F]): StateT[F, C, D] =
    new StateT(F.map(runF)(run => (c:C) => F.map(run(f(c)))(p => ((???) , g(p._2))) ))

I need a C in the place of ??? but in p I got only a S

@vmarquez
Copy link

vmarquez commented May 27, 2016

Err, I think I pointed out _Indexed_StateT is one. :-)

@kailuowang
Copy link
Contributor

ah, makes sense. since cats doesn't have IndexedStateT shall we close this one?

@ceedubs
Copy link
Contributor Author

ceedubs commented May 31, 2016

Oops I hadn't thought that through very well :)

Sorry for the false alert. Thanks for giving it a try @kailuowang and thanks for your input, @vmarquez.

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