ghc-magic-dict-compat-0.0.0.0: A compatibility layer and GHC plugin for `withDict` from "GHC.Magic.Dict".
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Magic.Dict.Plugin

Description

A type-checker plugin to resolve WithDict constraints for GHC <9.4; it is just a no-op for GHC >=9.4.

This plugin is inteded to be used with the compatibility layer exposed from GHC.Magic.Dict.Compat. For GHC <9.4, the definitions of WithDict and withDict are slightly different from those of GHC >= 9.4 to prevent user-defined instances.

Example usage:

{-# LANGUAGE RankNTypes, ScopedTypeVariables, TypeApplications, ConstraintKinds #-}
{-# GHC_OPTIONS -fplugin GHC.Magic.Dict.Plugin #-}
module MyModule where
import GHC.Magic.Dict.Compat

class Given a where
  given :: a

give :: a -> (Given a => r) -> r
give = withDict @(Given a) @a

For GHC >=9.4, this module just re-exports the module GHC.Magic.Dict and the plugin is just a no-op - so you can safely use this package without concerning break anything in newer GHCs.

Documentation