@hackage / ghc-typelits-natnormalise

GHC typechecker plugin for types of kind GHC.TypeLits.Nat

Latest0.9.5

About

Metadata

  • Last updated , by QBayLogic
  • License BSD-2-Clause
  • Categories Type System
  • Maintained by: christiaan.baaij@gmail.com

  • Lottery factor: 2

Links

Installation

Tested Compilers

  1. 9.12.2
  2. 9.10.2
  3. 9.8.4
  4. 9.6.7
  5. 9.4.8
  6. 9.2.8
  7. 9.0.2
  8. 8.10.7
  9. 8.8.4

Package Flags

Use the -f option with cabal commands to enable flags

    deverror (off by default)

    Enables `-Werror` for development mode and TravisCI

Readme

ghc-typelits-natnormalise

Build Status Hackage Hackage Dependencies

A type checker plugin for GHC that can solve equalities and inequalities of types of kind Nat, where these types are either:

  • Type-level naturals
  • Type variables
  • Applications of the arithmetic expressions (+,-,*,^).

It solves these equalities by normalising them to sort-of SOP (Sum-of-Products) form, and then perform a simple syntactic equality.

For example, this solver can prove the equality between:

(x + 2)^(y + 2)

and

4*x*(2 + x)^y + 4*(2 + x)^y + (2 + x)^y*x^2

Because the latter is actually the SOP normal form of the former.

To use the plugin, add

{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}

To the header of your file.