Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE
ghc-runmemo
ghc-runmemo.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ghc-runmemo.spec of Package ghc-runmemo
# # spec file for package ghc-runmemo # # 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 runmemo %bcond_with tests Name: ghc-%{pkg_name} Version: 1.0.0.1 Release: 0 Summary: A simple memoization helper library License: BSD-3-Clause Group: Development/Libraries/Haskell 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-rpm-macros %if %{with tests} BuildRequires: ghc-data-memocombinators-devel BuildRequires: ghc-time-devel %endif %description This library encourages you to do memoization in three separate steps: (1) Create a memoizable function (2) Create or select an appropriate memoizer (3) Run the memoizer on the memoizable function Let's start with the first. When you create a memoizable function, you should use the 'self' convention, which is that the first input to the function is 'self', and all recursive calls are replaced with 'self'. One common convention that goes well with the 'self' convention is using a helper function 'go', like so: ' fib :: Memoizable (Integer -> Integer) fib self = go where go 0 = 1 go 1 = 1 go n = self (n-1) + self (n-2) ' Now for the second. For this example, we need a Memoizer that can handle an 'Integer' input, and an 'Integer' output. 'Data.MemoCombinators' provides 'integral', which handles any 'Integral' input, and any output. 'Data.MemoUgly' provides 'memo', which can memoize any function 'a -> b', given an 'Ord' instance for 'a'. Third, let's run our memoizers! Since we have decoupled the definition of the memoized function from its actual memoization, we can create multiple memoized versions of the same function if we so desire. ' import qualified Data.MemoUgly as Ugly import qualified Data.MemoCombinators as MC fibUgly :: Integer -> Integer fibUgly = runMemo Ugly.memo fib fibMC :: Integer -> Integer fibMC = runMemo MC.integral fib ' You could easily do the same with 'Data.MemoTrie.memo', 'Data.Function.Memoize.memoize', etc. Using this technique, you can create local memoized functions whose memo tables are garbage collected as soon as they are no longer needed. %package devel Summary: Haskell %{pkg_name} library development files Group: Development/Libraries/Haskell 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 %doc LICENSE %files devel -f %{name}-devel.files %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor