File ghc-ghc-typelits-knownnat.spec of Package ghc-ghc-typelits-knownnat

#
# spec file for package ghc-ghc-typelits-knownnat
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%global pkg_name ghc-typelits-knownnat
%bcond_with tests
Name:           ghc-%{pkg_name}
Version:        0.3
Release:        0
Summary:        Derive KnownNat constraints from other KnownNat constraints
License:        BSD-2-Clause
Group:          Development/Languages/Other
Url:            https://hackage.haskell.org/package/%{pkg_name}
Source0:        https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-ghc-devel
BuildRequires:  ghc-ghc-tcplugins-extra-devel
BuildRequires:  ghc-ghc-typelits-natnormalise-devel
BuildRequires:  ghc-rpm-macros
BuildRequires:  ghc-singletons-devel
BuildRequires:  ghc-template-haskell-devel
BuildRequires:  ghc-transformers-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{with tests}
BuildRequires:  ghc-tasty-devel
BuildRequires:  ghc-tasty-hunit-devel
BuildRequires:  ghc-tasty-quickcheck-devel
%endif

%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 derive 'KnownNat' constraints for types consisting of:

* Type variables, when there is a corresponding 'KnownNat' constraint

* Type-level naturals

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

* Type functions, when there is either:

1. a matching given 'KnownNat' constraint; or

2. a 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.

%package devel
Summary:        Haskell %{pkg_name} library development files
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}-%{release}
Requires:       ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
Requires(postun): ghc-compiler = %{ghc_version}

%description devel
This package provides the Haskell %{pkg_name} library development
files.

%prep
%setup -q -n %{pkg_name}-%{version}

%build
%ghc_lib_build

%install
%ghc_lib_install

%check
%cabal_test

%post devel
%ghc_pkg_recache

%postun devel
%ghc_pkg_recache

%files -f %{name}.files
%defattr(-,root,root,-)
%doc LICENSE

%files devel -f %{name}-devel.files
%defattr(-,root,root,-)
%doc CHANGELOG.md README.md

%changelog
openSUSE Build Service is sponsored by