Skip to content

Instantly share code, notes, and snippets.

@kosmikus
Created September 25, 2019 12:18
Show Gist options
  • Save kosmikus/7ab13c90134640d4ad62c69233ea152e to your computer and use it in GitHub Desktop.
Save kosmikus/7ab13c90134640d4ad62c69233ea152e to your computer and use it in GitHub Desktop.
{-# LANGUAGE DerivingVia, ScopedTypeVariables, StandaloneDeriving, TypeApplications, TypeFamilies #-}
module DataFamilyDerivingVia where
import Data.Coerce
data family Foo a
newtype ByBar a = ByBar a
class Baz a where
baz :: a -> a
instance Baz (ByBar a) where
baz = id
-- deriving via ByBar (Foo a) instance Baz (Foo a)
instance Baz (Foo a) where
baz = coerce @(ByBar (Foo a) -> ByBar (Foo a)) @(Foo a -> Foo a) baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment