| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell98 |
Deriving.On
Documentation
With DerivingVia: to derive non-structural instances. Specifies
what field to base instances on.
The type is compared and evaluated based only
on the On User "userID""userID" record field. This uses HasField from
GHC.Records to project the relevant component.
{--}
{--}
{--}
import Deriving.On
import Data.Hashable
data User = User
{ name :: String
, age :: Int
, userID :: Integer
}
deriving (Eq, Ord, Hashable)
via User On "userID"
>> alice = User Alice 50 0xDEADBEAF >> bob = User Bob 20 0xDEADBEAF >> >> alice == bob True >> alice <= bob True >> hash alice == hash bob True
Constructors
| On a |
Instances
| (HasField field a b, Eq b) => Eq (On a field) Source # | |
| (HasField field a b, Ord b) => Ord (On a field) Source # | |
| (HasField field a b, Hashable b) => Hashable (On a field) Source # | |
Defined in Deriving.On | |