File ghc-validation.spec of Package ghc-validation

#
# spec file for package ghc-validation
#
# Copyright (c) 2016 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 validation
%bcond_with tests
Name:           ghc-%{pkg_name}
Version:        0.5.4
Release:        0
Summary:        A data-type like Either but with an accumulating Applicative
License:        BSD-3-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-bifunctors-devel
BuildRequires:  ghc-lens-devel
BuildRequires:  ghc-mtl-devel
BuildRequires:  ghc-rpm-macros
BuildRequires:  ghc-semigroupoids-devel
BuildRequires:  ghc-semigroups-devel
BuildRequires:  ghc-transformers-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{with tests}
BuildRequires:  ghc-QuickCheck-devel
BuildRequires:  ghc-directory-devel
BuildRequires:  ghc-doctest-devel
BuildRequires:  ghc-filepath-devel
BuildRequires:  ghc-template-haskell-devel
%endif

%description
<<http://i.imgur.com/Ns5hntl.jpg>>

Several data-types like Either but with differing properties and type-class
instances.

Library support is provided for those different representations, include
`lens`-related functions for converting between each and abstracting over their
similarities.

* `AccValidation`

The `AccValidation` data type is isomorphic to `Either`, but has an instance of
`Applicative` that accumulates on the error side. That is to say, if two (or
more) errors are encountered, they are appended using a `Semigroup` operation.

As a consequence of this `Applicative` instance, there is no corresponding
`Bind` or `Monad` instance. `AccValidation` is an example of, "An applicative
functor that is not a monad."

* `Validation`

The `Validation` data type is isomorphic to `Either` and has a `Monad` instance
that does the same as `Either`. The only difference to `Either` is the
constructor names and surrounding library support.

* `ValidationT`

The `ValidationT` data type is the monad transformer for `Validation`.
An instance of `MonadTrans` is provided for `(ValidationT err)`. Due to the
arrangement of the `ValidationT` type constructor, which permits a `MonadTrans
instance, there is no possible `Bifunctor` instance. Consequently, the
`ValidationB` data type provides a `Bifunctor` instance (but not a `MonadTrans`
instance). Library support is provided to exploit the isomorphism to
`ValidationB`.

Note that since `AccValidation` is not a monad, there is also no corresponding
monad transformer for this data type.

* `ValidationB`

The `ValidationB` data type is similar to the monad transformer for
`Validation` (`ValidationT`), however, due to the arrangement of the
`ValidationB` type constructor, which permits a `Bifunctor` instance, there is
no possible `MonadTrans` instance. Consequently, the `ValidationT` data type
provides a `MonadTrans` instance (but not a `Bifunctor` instance).
Library support is provided to exploit the isomorphism to `ValidationT`.

* `Validation'`

The `Validation' err a` type-alias is equivalent to `ValidationT err Identity
a` and so is isomorphic to `Either` and others. Libraries are supplied
accordingly.

%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

%changelog