name: ghc-typelits-knownnat
version: 0.1.1
synopsis: Derive KnownNat constraints from other KnownNat constraints
description:
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.
homepage: http://clash-lang.org/
license: BSD2
license-file: LICENSE
author: Christiaan Baaij
maintainer: christiaan.baaij@gmail.com
copyright: Copyright © 2016 University of Twente
category: Type System
build-type: Simple
extra-source-files: README.md
CHANGELOG.md
cabal-version: >=1.10
source-repository head
type: git
location: https://github.com/clash-lang/ghc-typelits-knownnat.git
flag deverror
description:
Enables `-Werror` for development mode and TravisCI
default: False
manual: True
library
exposed-modules: GHC.TypeLits.KnownNat.Solver,
GHC.TypeLits.KnownNat
other-extensions: AllowAmbiguousTypes
DataKinds
FlexibleInstances
MultiParamTypeClasses
KindSignatures
ScopedTypeVariables
TupleSections
TypeApplications
TypeOperators
build-depends: base >= 4.9 && <4.10,
ghc >= 8.0.1 && <8.2,
ghc-tcplugins-extra >= 0.2
hs-source-dirs: src
default-language: Haskell2010
if flag(deverror)
ghc-options: -Wall -Werror
else
ghc-options: -Wall
test-suite test-ghc-typelits-knownat
type: exitcode-stdio-1.0
main-is: Main.hs
build-depends: base >= 4.8 && <5,
ghc-typelits-knownnat >= 0.1,
tasty >= 0.10,
tasty-hunit >= 0.9
hs-source-dirs: tests
default-language: Haskell2010
other-extensions: DataKinds
ScopedTypeVariables
TypeApplications
TypeOperators
if flag(deverror)
ghc-options: -O0 -dcore-lint