# ghc-typelits-knownnat: Derive KnownNat constraints from other KnownNat constraints

A type checker plugin for GHC that can derive "complex" `KnownNat`

constraints from other simple/variable `KnownNat`

constraints. i.e. without
this plugin, you must have both a `KnownNat n`

and a `KnownNat (n+2)`

constraint in the type signature of the following function:

f :: forall n . (KnownNat n, KnownNat (n+2)) => Proxy n -> Integer f _ = natVal (Proxy :: Proxy n) + natVal (Proxy :: Proxy (n+2))

Using the plugin you can omit the `KnownNat (n+2)`

constraint:

f :: forall n . KnownNat n => Proxy n -> Integer f _ = natVal (Proxy :: Proxy n) + natVal (Proxy :: Proxy (n+2))

The plugin can only derive `KnownNat`

constraints consisting of:

Type-level naturals

Type variables

Applications of the arithmetic expression: +,*,^

i.e. it *cannot* derive a `KnownNat (n-1)`

constraint from a `KnownNat n`

constraint

To use the plugin, add the

OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver

Pragma to the header of your file.

[Skip to Readme]

Versions [faq] | 0.1, 0.1.1, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3, 0.3.1, 0.4, 0.4.1, 0.4.2, 0.5, 0.5.1, 0.6 |
---|---|

Change log | CHANGELOG.md |

Dependencies | base (==4.9.*), ghc (>=8.0.1 && <8.2), ghc-tcplugins-extra (>=0.2) [details] |

License | BSD-2-Clause |

Copyright | Copyright © 2016 University of Twente |

Author | Christiaan Baaij |

Maintainer | christiaan.baaij@gmail.com |

Category | Type System |

Home page | http://clash-lang.org/ |

Source repo | head: git clone https://github.com/clash-lang/ghc-typelits-knownnat.git |

Uploaded | by ChristiaanBaaij at Thu Aug 11 08:40:34 UTC 2016 |

Distributions | Arch:0.6, LTSHaskell:0.6, NixOS:0.6, Stackage:0.6 |

Downloads | 5303 total (444 in the last 30 days) |

Rating | (no votes yet) [estimated by rule of succession] |

Your Rating | |

Status | Docs uploaded by user Build status unknown [no reports yet] |

## Flags

Name | Description | Default | Type |
---|---|---|---|

deverror | Enables | Disabled | Manual |

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

## Downloads

- ghc-typelits-knownnat-0.1.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)