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

Simplify the applicative instance of Free #199

Open
ianliu opened this issue Jul 31, 2020 · 2 comments
Open

Simplify the applicative instance of Free #199

ianliu opened this issue Jul 31, 2020 · 2 comments

Comments

@ianliu
Copy link

ianliu commented Jul 31, 2020

Is it possible to simplify the following two lines

Pure a <*> Pure b = Pure $ a b
Pure a <*> Free mb = Free $ fmap a <$> mb

to this?

  (Pure a) <*> b = fmap a b

I'm still learning Haskell and I was trying to implement the Free monad myself and came here to compare my implementation with yours; so I apologize in advance if this "issue" is just plain bogus.

Thanks,
Ian

@RyanGlScott
Copy link
Collaborator

Yes, those are equivalent as far as I can tell.

@Icelandjack
Copy link

Yes and a lot clearer, this part of the Applicative docs becomes relevant

As a consequence of these laws, the Functor instance for f will satisfy

fmap f x = pure f <*> x

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