@hackage / stock-hashable

Derive Hashable via the stock plugin

Latest0.1.0.0

About

Metadata

  • Last updated , by BaldurBlondal
  • License BSD-3-Clause
  • Categories Type System
  • Maintained by: baldur.blondal@iohk.io

  • Lottery factor: 0

Links

Installation

Tested Compilers

  1. 9.10.3
  2. 9.10.3
  3. 9.8.1

Readme

The stock plugin provides a newtype Stock for deriving and synthesising instances at compile time. stock-hashable extends it to support Hashable, and higher-kinded variants.

{-# options_ghc -fplugin Stock #-}

{-# language DerivingVia #-}

import Stock
import Stock.Hashable

data Pair a b = Pair a b
 deriving (Eq,  Hashable)  via Stock  (Pair a b)
 deriving (Eq1, Hashable1) via Stock1 (Pair a)
 deriving (Eq2, Hashable2) via Stock2 Pair

stock-hashable provides three instances, that signal to the plugin how to derive Hashable, Hashable1 and Hashable2.

instance DeriveStock  Hashable  ..
instance DeriveStock1 Hashable1 ..
instance DeriveStock2 Hashable2 ..

stock companion packages include: