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

Floating instance for behaviors? #465

Open
noughtmare opened this issue Jan 16, 2022 · 3 comments
Open

Floating instance for behaviors? #465

noughtmare opened this issue Jan 16, 2022 · 3 comments

Comments

@noughtmare
Copy link

noughtmare commented Jan 16, 2022

I think this instance should work:

instance (Reflex t, Floating a) => Floating (Behavior t a) where
  pi = pure pi
  exp = fmap exp
  log = fmap log
  sqrt = fmap sqrt
  (**) = liftA2 (**)
  logBase = liftA2 logBase
  sin = fmap sin
  cos = fmap cos
  asin = fmap asin
  acos = fmap acos
  atan = fmap atan
  sinh = fmap sinh
  cosh = fmap cosh
  asinh = fmap asinh
  acosh = fmap acosh
  atanh = fmap atanh
@Ericson2314
Copy link
Member

I am not so sure this is a good idea? This is true for any Applicative, and I prefer to be explicit about operation on the side vs on the functor "container".

@noughtmare
Copy link
Author

There are already similar instances for Semigroup, Monoid, Num, and Fractional, so to me it's strange to draw the line here.

@noughtmare
Copy link
Author

I also noticed that there are Semigroup, Monoid and Num instances for Dynamic but no Fractional or Floating instances.

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

2 participants