if-instance- Branch on whether a constraint is satisfied
Safe HaskellSafe-Inferred




plugin :: Plugin Source #

A type-checking plugin that solves ct_l || ct_r constraints. This allows users to branch on whether ct_l is satisfied.

To use this plugin, add {-# OPTIONS_GHC -fplugin=IfSat.Plugin #-} to your module header.

A ct_l || ct_r instance is solved by trying to solve ct_l:

  • if solving succeeds, the dispatch function will pick the first branch,
  • otherwise, dispatch will pick the second branch.

This means that the branch selection occurs precisely at the moment at which we solve the ct_l || ct_r constraint. See the documentation of dispatch for more information.