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

Adding lift and inspect to StateT #1169

Merged
merged 3 commits into from
Jul 13, 2016
Merged

Conversation

zainab-ali
Copy link
Contributor

@zainab-ali zainab-ali commented Jun 29, 2016

Adding utility functions lift and inspect to the StateT object.

@codecov-io
Copy link

codecov-io commented Jun 29, 2016

Current coverage is 88.81%

Merging #1169 into master will increase coverage by <.01%

@@             master      #1169   diff @@
==========================================
  Files           232        233     +1   
  Lines          3073       3084    +11   
  Methods        3021       3033    +12   
  Messages          0          0          
  Branches         49         48     -1   
==========================================
+ Hits           2729       2739    +10   
- Misses          344        345     +1   
  Partials          0          0          

Sunburst

Powered by Codecov. Last updated by a639f66...90a2280

@zainab-ali zainab-ali changed the title Adding lift and modify to StateT Adding lift and inspect to StateT Jun 29, 2016
StateT(s => F.map(fa)(a => (s, a)))

def inspect[F[_], S, A](f: S => F[A])(implicit F: Applicative[F]): StateT[F, S, A] =
StateT(s => F.map(f(s))(a => (s, a)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have inspect take S => A and create a separate inspectF for S => F[A]? It seems like the simple S => A case might be pretty common, so it might be nice to make it concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'm thinking of adding a modify taking S => S and a modifyF taking S => F[S] while
I'm at it.

@ceedubs
Copy link
Contributor

ceedubs commented Jul 13, 2016

👍 looks great to me. Thanks @zainab-ali!

@kailuowang
Copy link
Contributor

👍 many thanks!

@kailuowang kailuowang merged commit fe361a3 into typelevel:master Jul 13, 2016
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.

4 participants