gnu: Add ghc-hashable.
[jackhill/guix/guix.git] / gnu / packages / haskell.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages haskell)
20 #:use-module (ice-9 regex)
21 #:use-module ((guix licenses) #:select (bsd-3))
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix utils)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix build-system haskell)
27 #:use-module (gnu packages perl)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages elf)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages ghostscript)
32 #:use-module (gnu packages libffi)
33 #:use-module (gnu packages libedit)
34 #:use-module (gnu packages multiprecision)
35 #:use-module (gnu packages ncurses)
36 #:use-module (gnu packages python))
37
38 (define ghc-bootstrap-x86_64-7.8.4
39 (origin
40 (method url-fetch)
41 (uri
42 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-x86_64-unknown-linux-deb7.tar.xz")
43 (sha256
44 (base32
45 "13azsl53xgj20mi1hj9x0xb32vvcvs6cpmvwx6znxhas7blh0bpn"))))
46
47 (define ghc-bootstrap-i686-7.8.4
48 (origin
49 (method url-fetch)
50 (uri
51 "https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-i386-unknown-linux-deb7.tar.xz")
52 (sha256
53 (base32
54 "0wj5s435j0zgww70bj1d3f6wvnnpzlxwvwcyh2qv4qjq5z8j64kg"))))
55
56 ;; 43 tests out of 3965 fail.
57 ;;
58 ;; Most of them do not appear to be serious:
59 ;;
60 ;; - some tests generate files referring to "/bin/sh" and "/bin/ls". I've not
61 ;; figured out how these references are generated.
62 ;;
63 ;; - Some tests allocate more memory than expected (ca. 3% above upper limit)
64 ;;
65 ;; - Some tests try to load unavailable libriries: Control.Concurrent.STM,
66 ;; Data.Vector, Control.Monad.State.
67 ;;
68 ;; - Test posix010 tries to check the existence of a user on the system:
69 ;; getUserEntryForName: does not exist (no such user)
70 (define-public ghc
71 (package
72 (name "ghc")
73 (version "7.8.4")
74 (source
75 (origin
76 (method url-fetch)
77 (uri (string-append "https://www.haskell.org/ghc/dist/"
78 version "/" name "-" version "-src.tar.xz"))
79 (sha256
80 (base32
81 "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3"))))
82 (build-system gnu-build-system)
83 (supported-systems '("i686-linux" "x86_64-linux"))
84 (outputs '("out" "doc"))
85 (inputs
86 `(("gmp" ,gmp)
87 ("ncurses" ,ncurses)
88 ("libffi" ,libffi)
89 ("libedit" ,libedit)
90 ("ghc-testsuite"
91 ,(origin
92 (method url-fetch)
93 (uri (string-append
94 "https://www.haskell.org/ghc/dist/"
95 version "/" name "-" version "-testsuite.tar.xz"))
96 (sha256
97 (base32
98 "0q95whf87y4mxjzwzy899g7z7l9pazq4si6iciyhxkcdhqq2ycyh"))))))
99 (native-inputs
100 `(("perl" ,perl)
101 ("python" ,python-2) ; for tests (fails with python-3)
102 ("ghostscript" ,ghostscript) ; for tests
103 ("patchelf" ,patchelf)
104 ;; GHC is built with GHC. Therefore we need bootstrap binaries.
105 ("ghc-binary"
106 ,(if (string-match "x86_64" (or (%current-target-system) (%current-system)))
107 ghc-bootstrap-x86_64-7.8.4
108 ghc-bootstrap-i686-7.8.4))))
109 (arguments
110 `(#:test-target "test"
111 ;; We get a smaller number of test failures by disabling parallel test
112 ;; execution.
113 #:parallel-tests? #f
114 #:modules ((guix build gnu-build-system)
115 (guix build utils)
116 (guix build rpath)
117 (srfi srfi-26)
118 (srfi srfi-1))
119 #:imported-modules ((guix build gnu-build-system)
120 (guix build utils)
121 (guix build rpath))
122 #:configure-flags
123 (list
124 (string-append "--with-gmp-libraries="
125 (assoc-ref %build-inputs "gmp") "/lib")
126 (string-append "--with-gmp-includes="
127 (assoc-ref %build-inputs "gmp") "/include")
128 "--with-system-libffi"
129 (string-append "--with-ffi-libraries="
130 (assoc-ref %build-inputs "libffi") "/lib")
131 (string-append "--with-ffi-includes="
132 (assoc-ref %build-inputs "libffi") "/include"))
133 ;; FIXME: The user-guide needs dblatex, docbook-xsl and docbook-utils.
134 ;; Currently we do not have the last one.
135 ;; #:make-flags
136 ;; (list "BUILD_DOCBOOK_HTML = YES")
137 #:phases
138 (let* ((ghc-bootstrap-path
139 (string-append (getcwd) "/" ,name "-" ,version "/ghc-bin"))
140 (ghc-bootstrap-prefix
141 (string-append ghc-bootstrap-path "/usr" )))
142 (alist-cons-after
143 'unpack-bin 'unpack-and-fix-testsuite
144 (lambda* (#:key inputs outputs #:allow-other-keys)
145 (with-directory-excursion ".."
146 (copy-file (assoc-ref inputs "ghc-testsuite")
147 "ghc-testsuite.tar.xz")
148 (system* "tar" "xvf" "ghc-testsuite.tar.xz"))
149 (substitute*
150 (list "testsuite/timeout/Makefile"
151 "testsuite/timeout/timeout.py"
152 "testsuite/timeout/timeout.hs"
153 "testsuite/tests/rename/prog006/Setup.lhs"
154 "testsuite/tests/programs/life_space_leak/life.test")
155 (("/bin/sh") (which "sh"))
156 (("/bin/rm") "rm"))
157 #t)
158 (alist-cons-after
159 'unpack 'unpack-bin
160 (lambda* (#:key inputs outputs #:allow-other-keys)
161 (mkdir-p ghc-bootstrap-prefix)
162 (with-directory-excursion ghc-bootstrap-path
163 (copy-file (assoc-ref inputs "ghc-binary")
164 "ghc-bin.tar.xz")
165 (zero? (system* "tar" "xvf" "ghc-bin.tar.xz"))))
166 (alist-cons-before
167 'install-bin 'configure-bin
168 (lambda* (#:key inputs outputs #:allow-other-keys)
169 (let* ((binaries
170 (list
171 "./utils/ghc-pwd/dist-install/build/tmp/ghc-pwd"
172 "./utils/hpc/dist-install/build/tmp/hpc"
173 "./utils/haddock/dist/build/tmp/haddock"
174 "./utils/hsc2hs/dist-install/build/tmp/hsc2hs"
175 "./utils/runghc/dist-install/build/tmp/runghc"
176 "./utils/ghc-cabal/dist-install/build/tmp/ghc-cabal"
177 "./utils/hp2ps/dist/build/tmp/hp2ps"
178 "./utils/ghc-pkg/dist-install/build/tmp/ghc-pkg"
179 "./utils/unlit/dist/build/tmp/unlit"
180 "./ghc/stage2/build/tmp/ghc-stage2"))
181 (gmp (assoc-ref inputs "gmp"))
182 (gmp-lib (string-append gmp "/lib"))
183 (gmp-include (string-append gmp "/include"))
184 (ncurses-lib
185 (string-append (assoc-ref inputs "ncurses") "/lib"))
186 (ld-so (string-append (assoc-ref inputs "libc")
187 ,(glibc-dynamic-linker)))
188 (libtinfo-dir
189 (string-append ghc-bootstrap-prefix
190 "/lib/ghc-7.8.4/terminfo-0.4.0.0")))
191 (with-directory-excursion
192 (string-append ghc-bootstrap-path "/" ,name "-" ,version)
193 (setenv "CONFIG_SHELL" (which "bash"))
194 (setenv "LD_LIBRARY_PATH" gmp-lib)
195 ;; The binaries have "/lib64/ld-linux-x86-64.so.2" hardcoded.
196 (for-each
197 (cut system* "patchelf" "--set-interpreter" ld-so <>)
198 binaries)
199 ;; The binaries include a reference to libtinfo.so.5 which
200 ;; is a subset of libncurses.so.5. We create a symlink in a
201 ;; directory included in the bootstrap binaries rpath.
202 (mkdir-p libtinfo-dir)
203 (symlink
204 (string-append ncurses-lib "/libncursesw.so."
205 ,(version-major+minor
206 (package-version ncurses)))
207 (string-append libtinfo-dir "/libtinfo.so.5"))
208 (setenv "PATH"
209 (string-append (getenv "PATH") ":"
210 ghc-bootstrap-prefix "/bin"))
211 (system*
212 (string-append (getcwd) "/configure")
213 (string-append "--prefix=" ghc-bootstrap-prefix)
214 (string-append "--with-gmp-libraries=" gmp-lib)
215 (string-append "--with-gmp-includes=" gmp-include)))))
216 (alist-cons-before
217 'configure 'install-bin
218 (lambda* (#:key inputs outputs #:allow-other-keys)
219 (with-directory-excursion
220 (string-append ghc-bootstrap-path "/" ,name "-" ,version)
221 (zero? (system* "make" "install"))))
222 %standard-phases)))))))
223 (home-page "https://www.haskell.org/ghc")
224 (synopsis "The Glasgow Haskell Compiler")
225 (description
226 "The Glasgow Haskell Compiler (GHC) is a state-of-the-art compiler and
227 interactive environment for the functional language Haskell.")
228 (license bsd-3)))
229
230 (define-public ghc-mtl
231 (package
232 (name "ghc-mtl")
233 (version "2.1.3.1")
234 (outputs '("out" "doc"))
235 (source
236 (origin
237 (method url-fetch)
238 (uri (string-append
239 "http://hackage.haskell.org/package/mtl/mtl-"
240 version
241 ".tar.gz"))
242 (sha256
243 (base32
244 "1xpn2wjmqbh2cg1yssc6749xpgcqlrrg4iilwqgkcjgvaxlpdbvp"))))
245 (build-system haskell-build-system)
246 (home-page "http://github.com/ekmett/mtl")
247 (synopsis
248 "Monad classes, using functional dependencies")
249 (description
250 "Monad classes using functional dependencies, with instances
251 for various monad transformers, inspired by the paper
252 'Functional Programming with Overloading and Higher-Order Polymorphism',
253 by Mark P Jones, in 'Advanced School of Functional Programming', 1995
254 http://web.cecs.pdx.edu/~mpj/pubs/springschool.html.")
255 (license bsd-3)))
256
257 (define-public ghc-paths
258 (package
259 (name "ghc-paths")
260 (version "0.1.0.9")
261 (outputs '("out" "doc"))
262 (source
263 (origin
264 (method url-fetch)
265 (uri (string-append
266 "http://hackage.haskell.org/package/ghc-paths/ghc-paths-"
267 version
268 ".tar.gz"))
269 (sha256
270 (base32
271 "0ibrr1dxa35xx20cpp8jzgfak1rdmy344dfwq4vlq013c6w8z9mg"))))
272 (build-system haskell-build-system)
273 (home-page "https://github.com/simonmar/ghc-paths")
274 (synopsis
275 "Knowledge of GHC's installation directories")
276 (description
277 "Knowledge of GHC's installation directories.")
278 (license bsd-3)))
279
280 (define-public ghc-zlib
281 (package
282 (name "ghc-zlib")
283 (version "0.5.4.2")
284 (outputs '("out" "doc"))
285 (source
286 (origin
287 (method url-fetch)
288 (uri (string-append
289 "http://hackage.haskell.org/package/zlib/zlib-"
290 version
291 ".tar.gz"))
292 (sha256
293 (base32
294 "15hhsk7z3gvm7sz2ic2z1ca5c6rpsln2rr391mdbm1bxlzc1gmkm"))))
295 (build-system haskell-build-system)
296 (inputs `(("zlib" ,zlib)))
297 (home-page "http://hackage.haskell.org/package/zlib")
298 (synopsis
299 "Compression and decompression in the gzip and zlib formats")
300 (description
301 "This package provides a pure interface for compressing and decompressing
302 streams of data represented as lazy 'ByteString's. It uses the zlib C library
303 so it has high performance. It supports the 'zlib', 'gzip' and 'raw'
304 compression formats. It provides a convenient high level API suitable for
305 most tasks and for the few cases where more control is needed it provides
306 access to the full zlib feature set.")
307 (license bsd-3)))
308
309 (define-public ghc-stm
310 (package
311 (name "ghc-stm")
312 (version "2.4.4")
313 (outputs '("out" "doc"))
314 (source
315 (origin
316 (method url-fetch)
317 (uri (string-append
318 "http://hackage.haskell.org/package/stm/stm-"
319 version
320 ".tar.gz"))
321 (sha256
322 (base32
323 "0gc8zvdijp3rwmidkpxv76b4i0dc8dw6nbd92rxl4vxl0655iysx"))))
324 (build-system haskell-build-system)
325 (home-page "http://hackage.haskell.org/package/stm")
326 (synopsis "Software Transactional Memory")
327 (description
328 "A modular composable concurrency abstraction.")
329 (license bsd-3)))
330
331 (define-public ghc-parallel
332 (package
333 (name "ghc-parallel")
334 (version "3.2.0.6")
335 (outputs '("out" "doc"))
336 (source
337 (origin
338 (method url-fetch)
339 (uri (string-append
340 "http://hackage.haskell.org/package/parallel/parallel-"
341 version
342 ".tar.gz"))
343 (sha256
344 (base32
345 "0hp6vf4zxsw6vz6lj505xihmnfhgjp39c9q7nyzlgcmps3xx6a5r"))))
346 (build-system haskell-build-system)
347 (home-page "http://hackage.haskell.org/package/parallel")
348 (synopsis "Parallel programming library")
349 (description
350 "This package provides a library for parallel programming.")
351 (license bsd-3)))
352
353 (define-public ghc-text
354 (package
355 (name "ghc-text")
356 (version "1.2.0.4")
357 (outputs '("out" "doc"))
358 (source
359 (origin
360 (method url-fetch)
361 (uri (string-append
362 "http://hackage.haskell.org/package/text/text-"
363 version
364 ".tar.gz"))
365 (sha256
366 (base32
367 "004p1c74crs8wmjafwsmw3mmycspq1j8fpm1lvfpq6acha7bnpc6"))))
368 (build-system haskell-build-system)
369 (arguments
370 `(#:tests? #f)) ; FIXME: currently missing libraries used for tests.
371 (home-page "https://github.com/bos/text")
372 (synopsis
373 "Efficient packed Unicode text type library.")
374 (description
375 "An efficient packed, immutable Unicode text type (both strict and
376 lazy), with a powerful loop fusion optimization framework.
377
378 The 'Text' type represents Unicode character strings, in a time and
379 space-efficient manner. This package provides text processing
380 capabilities that are optimized for performance critical use, both
381 in terms of large data quantities and high speed.")
382 (license bsd-3)))
383
384 (define-public ghc-hashable
385 (package
386 (name "ghc-hashable")
387 (version "1.2.3.2")
388 (outputs '("out" "doc"))
389 (source
390 (origin
391 (method url-fetch)
392 (uri (string-append
393 "http://hackage.haskell.org/package/hashable/hashable-"
394 version
395 ".tar.gz"))
396 (sha256
397 (base32
398 "0h9295pv2sgbaqlwpwbx2bap6nngm0jcdhkqham1wpjwyxqgqrlc"))))
399 (build-system haskell-build-system)
400 (arguments
401 `(#:tests? #f)) ; FIXME: currently missing libraries used for tests.
402 ;; these inputs are necessary to use this library
403 (propagated-inputs
404 `(("ghc-text" ,ghc-text)))
405 (home-page "http://github.com/tibbe/hashable")
406 (synopsis
407 "Class for types that can be converted to a hash value")
408 (description
409 "This package defines a class, 'Hashable', for types that can be
410 converted to a hash value. This class exists for the benefit of hashing-based
411 data structures. The package provides instances for basic types and a way to
412 combine hash values.")
413 (license bsd-3)))
414
415 ;;; haskell.scm ends here