Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. {-# LANGUAGE DerivingVia, ScopedTypeVariables, StandaloneDeriving, TypeApplications, TypeFamilies #-}
  2. module DataFamilyDerivingVia where
  3.  
  4. import Data.Coerce
  5.  
  6. data family Foo a
  7.  
  8. newtype ByBar a = ByBar a
  9.  
  10. class Baz a where
  11. baz :: a -> a
  12.  
  13. instance Baz (ByBar a) where
  14. baz = id
  15.  
  16. -- deriving via ByBar (Foo a) instance Baz (Foo a)
  17.  
  18. instance Baz (Foo a) where
  19. baz = coerce @(ByBar (Foo a) -> ByBar (Foo a)) @(Foo a -> Foo a) baz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement