2012-06-06 20:12:20 +02:00
|
|
|
#
|
2013-07-31 20:30:59 +02:00
|
|
|
# spec file for package ghc-random
|
2012-06-06 20:12:20 +02:00
|
|
|
#
|
2022-06-29 14:18:19 +02:00
|
|
|
# Copyright (c) 2022 SUSE LLC
|
2012-06-06 20:12:20 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2018-10-18 11:50:30 +02:00
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
2012-06-06 20:12:20 +02:00
|
|
|
#
|
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
|
2012-06-06 20:12:20 +02:00
|
|
|
%global pkg_name random
|
2023-03-30 10:26:47 +02:00
|
|
|
%global pkgver %{pkg_name}-%{version}
|
2021-08-17 11:54:17 +02:00
|
|
|
%bcond_with tests
|
2016-07-18 00:07:34 +02:00
|
|
|
Name: ghc-%{pkg_name}
|
2022-06-29 14:18:19 +02:00
|
|
|
Version: 1.2.1.1
|
2013-07-31 20:30:59 +02:00
|
|
|
Release: 0
|
2021-08-17 11:54:17 +02:00
|
|
|
Summary: Pseudo-random number generation
|
2012-06-06 20:12:20 +02:00
|
|
|
License: BSD-3-Clause
|
2017-08-15 16:03:54 +02:00
|
|
|
URL: https://hackage.haskell.org/package/%{pkg_name}
|
2016-07-18 00:07:34 +02:00
|
|
|
Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
|
2012-06-06 20:12:20 +02:00
|
|
|
BuildRequires: ghc-Cabal-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-base-devel
|
|
|
|
BuildRequires: ghc-base-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-bytestring-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-bytestring-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-deepseq-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-deepseq-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-mtl-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-mtl-prof
|
2013-07-31 20:30:59 +02:00
|
|
|
BuildRequires: ghc-rpm-macros
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-splitmix-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-splitmix-prof
|
2020-12-19 18:49:00 +01:00
|
|
|
ExcludeArch: %{ix86}
|
2021-08-17 11:54:17 +02:00
|
|
|
%if %{with tests}
|
|
|
|
BuildRequires: ghc-containers-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-containers-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-doctest-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-doctest-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-smallcheck-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-smallcheck-prof
|
2021-09-20 15:07:56 +02:00
|
|
|
BuildRequires: ghc-stm-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-stm-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-tasty-devel
|
|
|
|
BuildRequires: ghc-tasty-hunit-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-tasty-hunit-prof
|
2021-09-20 15:07:56 +02:00
|
|
|
BuildRequires: ghc-tasty-inspection-testing-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-tasty-inspection-testing-prof
|
|
|
|
BuildRequires: ghc-tasty-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
BuildRequires: ghc-tasty-smallcheck-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-tasty-smallcheck-prof
|
2021-09-20 15:07:56 +02:00
|
|
|
BuildRequires: ghc-transformers-devel
|
2023-03-30 10:26:47 +02:00
|
|
|
BuildRequires: ghc-transformers-prof
|
2021-08-17 11:54:17 +02:00
|
|
|
%endif
|
2012-06-06 20:12:20 +02:00
|
|
|
|
|
|
|
%description
|
2021-08-17 11:54:17 +02:00
|
|
|
This package provides basic pseudo-random number generation, including the
|
2014-11-06 20:24:48 +01:00
|
|
|
ability to split random number generators.
|
|
|
|
|
2021-08-17 11:54:17 +02:00
|
|
|
== "System.Random": pure pseudo-random number interface
|
|
|
|
|
|
|
|
In pure code, use 'System.Random.uniform' and 'System.Random.uniformR' from
|
|
|
|
"System.Random" to generate pseudo-random numbers with a pure pseudo-random
|
|
|
|
number generator like 'System.Random.StdGen'.
|
|
|
|
|
|
|
|
As an example, here is how you can simulate rolls of a six-sided die using
|
|
|
|
'System.Random.uniformR':
|
|
|
|
|
|
|
|
>>> let roll = uniformR (1, 6) :: RandomGen g => g -> (Word, g) >>> let rolls =
|
|
|
|
unfoldr (Just . roll) :: RandomGen g => g -> [Word] >>> let pureGen = mkStdGen
|
|
|
|
42 >>> take 10 (rolls pureGen) :: [Word] [1,1,3,2,4,5,3,4,6,2]
|
|
|
|
|
|
|
|
See "System.Random" for more details.
|
|
|
|
|
|
|
|
== "System.Random.Stateful": monadic pseudo-random number interface
|
|
|
|
|
|
|
|
In monadic code, use 'System.Random.Stateful.uniformM' and
|
|
|
|
'System.Random.Stateful.uniformRM' from "System.Random.Stateful" to generate
|
|
|
|
pseudo-random numbers with a monadic pseudo-random number generator, or using a
|
|
|
|
monadic adapter.
|
|
|
|
|
|
|
|
As an example, here is how you can simulate rolls of a six-sided die using
|
|
|
|
'System.Random.Stateful.uniformRM':
|
|
|
|
|
|
|
|
>>> let rollM = uniformRM (1, 6) :: StatefulGen g m => g -> m Word >>> let
|
|
|
|
pureGen = mkStdGen 42 >>> runStateGen_ pureGen (replicateM 10 . rollM) ::
|
|
|
|
[Word] [1,1,3,2,4,5,3,4,6,2]
|
|
|
|
|
2021-09-20 15:07:56 +02:00
|
|
|
The monadic adapter 'System.Random.Stateful.runStateGen_' is used here to lift
|
2021-08-17 11:54:17 +02:00
|
|
|
the pure pseudo-random number generator 'pureGen' into the
|
|
|
|
'System.Random.Stateful.StatefulGen' context.
|
|
|
|
|
|
|
|
The monadic interface can also be used with existing monadic pseudo-random
|
|
|
|
number generators. In this example, we use the one provided in the
|
|
|
|
<https://hackage.haskell.org/package/mwc-random mwc-random> package:
|
|
|
|
|
|
|
|
>>> import System.Random.MWC as MWC >>> let rollM = uniformRM (1, 6) ::
|
|
|
|
StatefulGen g m => g -> m Word >>> monadicGen <- MWC.create >>> replicateM 10
|
|
|
|
(rollM monadicGen) :: IO [Word] [2,3,6,6,4,4,3,1,5,4]
|
|
|
|
|
|
|
|
See "System.Random.Stateful" for more details.
|
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
%package devel
|
|
|
|
Summary: Haskell %{pkg_name} library development files
|
2016-07-18 00:07:34 +02:00
|
|
|
Requires: %{name} = %{version}-%{release}
|
2014-11-06 20:24:48 +01:00
|
|
|
Requires: ghc-compiler = %{ghc_version}
|
|
|
|
Requires(post): ghc-compiler = %{ghc_version}
|
|
|
|
Requires(postun): ghc-compiler = %{ghc_version}
|
2013-07-31 20:30:59 +02:00
|
|
|
|
|
|
|
%description devel
|
2014-11-06 20:24:48 +01:00
|
|
|
This package provides the Haskell %{pkg_name} library development files.
|
|
|
|
|
2023-03-30 10:26:47 +02:00
|
|
|
%package -n ghc-%{pkg_name}-doc
|
|
|
|
Summary: Haskell %{pkg_name} library documentation
|
|
|
|
Requires: ghc-filesystem
|
|
|
|
BuildArch: noarch
|
|
|
|
|
|
|
|
%description -n ghc-%{pkg_name}-doc
|
|
|
|
This package provides the Haskell %{pkg_name} library documentation.
|
|
|
|
|
|
|
|
%package -n ghc-%{pkg_name}-prof
|
|
|
|
Summary: Haskell %{pkg_name} profiling library
|
|
|
|
Requires: ghc-%{pkg_name}-devel = %{version}-%{release}
|
|
|
|
Supplements: (ghc-%{pkg_name}-devel and ghc-prof)
|
|
|
|
|
|
|
|
%description -n ghc-%{pkg_name}-prof
|
|
|
|
This package provides the Haskell %{pkg_name} profiling library.
|
|
|
|
|
2012-06-06 20:12:20 +02:00
|
|
|
%prep
|
2020-09-04 17:11:17 +02:00
|
|
|
%autosetup -n %{pkg_name}-%{version}
|
2012-06-06 20:12:20 +02:00
|
|
|
|
|
|
|
%build
|
|
|
|
%ghc_lib_build
|
|
|
|
|
|
|
|
%install
|
|
|
|
%ghc_lib_install
|
|
|
|
|
2021-08-17 11:54:17 +02:00
|
|
|
%check
|
|
|
|
%cabal_test
|
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
%post devel
|
|
|
|
%ghc_pkg_recache
|
2012-06-06 20:12:20 +02:00
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
%postun devel
|
|
|
|
%ghc_pkg_recache
|
2012-06-06 20:12:20 +02:00
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
%files -f %{name}.files
|
2018-04-26 09:43:10 +02:00
|
|
|
%license LICENSE
|
2012-06-06 20:12:20 +02:00
|
|
|
|
2013-07-31 20:30:59 +02:00
|
|
|
%files devel -f %{name}-devel.files
|
2017-02-28 11:40:37 +01:00
|
|
|
%doc CHANGELOG.md README.md
|
2012-06-06 20:12:20 +02:00
|
|
|
|
2023-03-30 10:26:47 +02:00
|
|
|
%files -n ghc-%{pkg_name}-doc -f ghc-%{pkg_name}-doc.files
|
|
|
|
%license LICENSE
|
|
|
|
|
|
|
|
%files -n ghc-%{pkg_name}-prof -f ghc-%{pkg_name}-prof.files
|
|
|
|
|
2012-06-06 20:12:20 +02:00
|
|
|
%changelog
|