Skip to content

DerivingVia is considered Safe

... but GND isn't!

{-# LANGUAGE Safe #-}
{-# LANGUAGE DerivingVia #-}
module Via where

newtype Down a = Down a

instance Eq a => Eq (Down a) where
    Down x == Down y = x == y

instance Ord a => Ord (Down a) where
    compare (Down x) (Down y) = compare y x

newtype Foo = Foo (Down Int)
  deriving stock Eq
  deriving Ord via Down Int

compiles.

With ghc-9.0.1 -ddump-hi Via.hs -fforce-recomp

...
trusted: safe
...

and no warnings or errors.

Edited by Oleg Grenrus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information