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

Deriving Via for several datatypes #201

Open
Icelandjack opened this issue Oct 15, 2020 · 1 comment
Open

Deriving Via for several datatypes #201

Icelandjack opened this issue Oct 15, 2020 · 1 comment

Comments

@Icelandjack
Copy link

If free is accepting via there are quite a few instances that can be derived

data Free.Final.Alt f a = ..
  deriving (Semigroup, Monoid)
  via Data.Monoid.Alt (Free.Final.Alt f) a
data Free.Alt f a = ..
  deriving (Semigroup, Monoid)
  via Data.Monoid.Alt (Free.Final.Alt f) a

  deriving (Functor, Applicative, Alternative)
  via Compose [] (AltF f)
newtype Trans.Free.ApT f g a = ..
 deriving (Functor, Applicative, Alternative)
 via Compose g (Trans.Free.ApF f g)

In any case I'm curious if there is any way we can derive the Free instances that isn't completely trivial.

@Icelandjack
Copy link
Author

Oh I guess Functor is attainable with this completely useless derivation

newtype F f a = F { runF :: forall r. (a -> r) -> (f r -> r) -> r }
 deriving Functor
 via Ran Identity (Monster f)

newtype Monster f r = Monster ((f r -> r) -> r)

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

1 participant