# The ghc-typelits-knownnat package

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 derive `KnownNat`

constraints for types consisting of:

Type variables, when there is a corresponding

`KnownNat`

constraintType-level naturals

Applications of the arithmetic expression: +,-,*,^

Type functions, when there is either:

a matching given

`KnownNat`

constraint; ora corresponding

`KnownNat<N>`

instance for the type function

To use the plugin, add the

OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver

Pragma to the header of your file.

[Skip to Readme]

## Properties

Versions | 0.1, 0.1.1, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3, 0.3.1 |
---|---|

Change log | CHANGELOG.md |

Dependencies | base (==4.9.*), ghc (>=8.0.1 && <8.2), ghc-tcplugins-extra (>=0.2), ghc-typelits-natnormalise (==0.5.*), singletons (>=2.2 && <3.0), template-haskell (>=2.11.0.0 && <2.13), transformers (>=0.5.2.0 && <0.6) [details] |

License | BSD2 |

Copyright | Copyright © 2016 University of Twente |

Author | Christiaan Baaij |

Maintainer | christiaan.baaij@gmail.com |

Category | Type System |

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

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

Uploaded | Wed Aug 17 09:35:49 UTC 2016 by ChristiaanBaaij |

Distributions | LTSHaskell:0.3.1, NixOS:0.3.1, Stackage:0.3.1, Tumbleweed:0.2.4 |

Downloads | 786 total (74 in the last 30 days) |

Rating | 0.0 (0 ratings) [clear rating] |

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

## 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.2.tar.gz [browse] (Cabal source package)
- Package description (included in the package)