gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / idris.scm
blobec3eb15d6340c45cc616188f9b011f7343777840
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org>
3 ;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
4 ;;; Copyright © 2018 Alex ter Weele <alex.ter.weele@gmail.com>
5 ;;; Copyright © 2019 Eric Bavier <bavier@member.fsf.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages idris)
23   #:use-module (gnu packages)
24   #:use-module (gnu packages haskell)
25   #:use-module (gnu packages haskell-check)
26   #:use-module (gnu packages haskell-web)
27   #:use-module (gnu packages libffi)
28   #:use-module (gnu packages multiprecision)
29   #:use-module (gnu packages ncurses)
30   #:use-module (gnu packages perl)
31   #:use-module (guix build-system gnu)
32   #:use-module (guix build-system haskell)
33   #:use-module (guix download)
34   #:use-module (guix git-download)
35   #:use-module ((guix licenses) #:prefix license:)
36   #:use-module (guix packages))
38 (define-public idris
39   (package
40     (name "idris")
41     (version "1.3.1")
42     (source (origin
43               (method url-fetch)
44               (uri (string-append
45                     "https://hackage.haskell.org/package/"
46                     "idris-" version "/idris-" version ".tar.gz"))
47               (sha256
48                (base32
49                 "0fn9h58l592j72njwma1ia48h8h87wi2rjqfxs7j2lfmvgfv18fi"))
50               (patches (search-patches "idris-test-no-node.patch"))))
51     (build-system haskell-build-system)
52     (native-inputs                      ;For tests
53      `(("perl" ,perl)
54        ("ghc-tasty" ,ghc-tasty)
55        ("ghc-tasty-golden" ,ghc-tasty-golden)
56        ("ghc-tasty-rerun" ,ghc-tasty-rerun)))
57     (inputs
58      `(("gmp" ,gmp)
59        ("ncurses" ,ncurses)
60        ("ghc-aeson" ,ghc-aeson)
61        ("ghc-annotated-wl-pprint" ,ghc-annotated-wl-pprint)
62        ("ghc-ansi-terminal" ,ghc-ansi-terminal)
63        ("ghc-ansi-wl-pprint" ,ghc-ansi-wl-pprint)
64        ("ghc-async" ,ghc-async)
65        ("ghc-base64-bytestring" ,ghc-base64-bytestring)
66        ("ghc-blaze-html" ,ghc-blaze-html)
67        ("ghc-blaze-markup" ,ghc-blaze-markup)
68        ("ghc-cheapskate" ,ghc-cheapskate)
69        ("ghc-code-page" ,ghc-code-page)
70        ("ghc-fingertree" ,ghc-fingertree)
71        ("ghc-fsnotify" ,ghc-fsnotify)
72        ("ghc-ieee754" ,ghc-ieee754)
73        ("ghc-libffi" ,ghc-libffi)
74        ("ghc-megaparsec" ,ghc-megaparsec)
75        ("ghc-network" ,ghc-network)
76        ("ghc-optparse-applicative" ,ghc-optparse-applicative)
77        ("ghc-regex-tdfa" ,ghc-regex-tdfa)
78        ("ghc-safe" ,ghc-safe)
79        ("ghc-split" ,ghc-split)
80        ("ghc-terminal-size" ,ghc-terminal-size)
81        ("ghc-text" ,ghc-text)
82        ("ghc-uniplate" ,ghc-uniplate)
83        ("ghc-unordered-containers" ,ghc-unordered-containers)
84        ("ghc-utf8-string" ,ghc-utf8-string)
85        ("ghc-vector" ,ghc-vector)
86        ("ghc-vector-binary-instances" ,ghc-vector-binary-instances)
87        ("ghc-zip-archive" ,ghc-zip-archive)))
88     (arguments
89      `(#:configure-flags
90        (list (string-append "--datasubdir="
91                             (assoc-ref %outputs "out") "/lib/idris")
92              "-fFFI" "-fGMP")
93        #:phases
94        (modify-phases %standard-phases
95          (add-before 'configure 'set-cc-command
96            (lambda _
97              (setenv "CC" "gcc")
98              #t))
99          (add-after 'install 'fix-libs-install-location
100            (lambda* (#:key outputs #:allow-other-keys)
101              (let* ((out (assoc-ref outputs "out"))
102                     (lib (string-append out "/lib/idris"))
103                     (modules (string-append lib "/libs")))
104                (for-each
105                 (lambda (module)
106                   (symlink (string-append modules "/" module)
107                            (string-append lib "/" module)))
108                 '("prelude" "base" "contrib" "effects" "pruviloj")))))
109          (delete 'check)                ;Run check later
110          (add-after 'install 'check
111            (lambda* (#:key outputs #:allow-other-keys #:rest args)
112              (let ((out (assoc-ref outputs "out")))
113                (setenv "TASTY_NUM_THREADS" (number->string (parallel-job-count)))
114                (setenv "IDRIS_CC" "gcc") ;Needed for creating executables
115                (setenv "PATH" (string-append out "/bin:" (getenv "PATH")))
116                (apply (assoc-ref %standard-phases 'check) args)))))))
117     (native-search-paths
118      (list (search-path-specification
119             (variable "IDRIS_LIBRARY_PATH")
120             (files '("lib/idris")))))
121     (home-page "http://www.idris-lang.org")
122     (synopsis "General purpose language with full dependent types")
123     (description "Idris is a general purpose language with full dependent
124 types.  It is compiled, with eager evaluation.  Dependent types allow types to
125 be predicated on values, meaning that some aspects of a program's behaviour
126 can be specified precisely in the type.  The language is closely related to
127 Epigram and Agda.")
128     (license license:bsd-3)))
130 ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
131 (define (idris-default-arguments name)
132   `(#:modules ((guix build gnu-build-system)
133                (guix build utils)
134                (ice-9 ftw)
135                (ice-9 match))
136     #:phases
137     (modify-phases %standard-phases
138       (delete 'configure)
139       (delete 'build)
140       (delete 'check)
141       (replace 'install
142         (lambda* (#:key inputs outputs #:allow-other-keys)
143           (let* ((out (assoc-ref outputs "out"))
144                  (idris (assoc-ref inputs "idris"))
145                  (idris-bin (string-append idris "/bin/idris"))
146                  (idris-libs (string-append idris "/lib/idris/libs"))
147                  (module-name (and (string-prefix? "idris-" ,name)
148                                    (substring ,name 6)))
149                  (ibcsubdir (string-append out "/lib/idris/" module-name))
150                  (ipkg (string-append module-name ".ipkg"))
151                  (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
152                  (idris-path (string-split idris-library-path #\:))
153                  (idris-path-files (apply append
154                                           (map (lambda (path)
155                                                  (map (lambda (dir)
156                                                         (string-append path "/" dir))
157                                                       (scandir path))) idris-path)))
158                  (idris-path-subdirs (filter (lambda (path)
159                                                (and path (match (stat:type (stat path))
160                                                            ('directory #t)
161                                                            (_ #f))))
162                                                     idris-path-files))
163                  (install-cmd (cons* idris-bin
164                                      "--ibcsubdir" ibcsubdir
165                                      "--build" ipkg
166                                      ;; only trigger a build, as --ibcsubdir
167                                      ;; already installs .ibc files.
169                                      (apply append (map (lambda (path)
170                                                           (list "--idrispath"
171                                                                 path))
172                                                         idris-path-subdirs)))))
173             ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
174             (apply system* install-cmd)
175             #t))))))
177 (define-public idris-lightyear
178   (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
179     (package
180       (name "idris-lightyear")
181       (version (git-version "0.1" "1" commit))
182       (source (origin
183                 (method git-fetch)
184                 (uri (git-reference
185                       (url "https://github.com/ziman/lightyear")
186                       (commit commit)))
187                 (file-name (git-file-name name version))
188                 (sha256
189                  (base32
190                   "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
191       (build-system gnu-build-system)
192       (native-inputs
193        `(("idris" ,idris)))
194       (arguments (idris-default-arguments name))
195       (home-page "https://github.com/ziman/lightyear")
196       (synopsis "Lightweight parser combinator library for Idris")
197       (description "Lightweight parser combinator library for Idris, inspired
198 by Parsec.  This package is used (almost) the same way as Parsec, except for one
199 difference: backtracking.")
200       (license license:bsd-2))))
202 (define-public idris-wl-pprint
203   (let ((commit "1d365fcf4ba075859844dbc5eb96a90f57b9f338"))
204     (package
205       (name "idris-wl-pprint")
206       (version (git-version "0.1" "1" commit))
207       (source (origin
208                 (method git-fetch)
209                 (uri (git-reference
210                       (url "https://github.com/shayan-najd/wl-pprint")
211                       (commit commit)))
212                 (file-name (git-file-name name version))
213                 (sha256
214                  (base32
215                   "0g7c3y9smifdz4sivi3qmvymhdr7v9kfq45fmfmmvkqcrix0spzn"))))
216       (build-system gnu-build-system)
217       (native-inputs
218        `(("idris" ,idris)))
219       (arguments (idris-default-arguments name))
220       (home-page "https://github.com/shayan-najd/wl-pprint")
221       (synopsis "Pretty printing library")
222       (description "A pretty printing library for Idris based on Phil Wadler's
223 paper A Prettier Printer and on Daan Leijen's extensions in the Haskell
224 wl-pprint library.")
225       (license license:bsd-2))))
227 (define-public idris-bifunctors
228   (let ((commit "53d06a6ccfe70c49c9ae8c8a4135981dd2173202"))
229     (package
230       (name "idris-bifunctors")
231       (version (git-version "0.1" "1" commit))
232       (source (origin
233                 (method git-fetch)
234                 (uri (git-reference
235                       (url "https://github.com/HuwCampbell/Idris-Bifunctors")
236                       (commit commit)))
237                 (file-name (string-append name "-" version "-checkout"))
238                 (sha256
239                  (base32
240                   "02vbsd3rmgnj0l1qq787709qcxjbr9890cbad4ykn27f77jk81h4"))))
241       (build-system gnu-build-system)
242       (native-inputs
243        `(("idris" ,idris)))
244       (arguments (idris-default-arguments name))
245       (home-page "https://github.com/HuwCampbell/Idris-Bifunctors")
246       (synopsis "Bifunctor library")
247       (description "This is a bifunctor library for Idris based off the
248 excellent Haskell Bifunctors package from Edward Kmett.")
249       (license license:bsd-3))))
251 (define-public idris-lens
252   (let ((commit "26f012005f6849806cea630afe317e42cae97f29"))
253     (package
254       (name "idris-lens")
255       (version (git-version "0.1" "1" commit))
256       (source (origin
257                 (method git-fetch)
258                 (uri (git-reference
259                       (url "https://github.com/HuwCampbell/idris-lens")
260                       (commit commit)))
261                 (file-name (git-file-name name version))
262                 (sha256
263                  (base32
264                   "06jzfj6rad08rk92w8jk5byi79svmyg0mrcqhibgx8rkjjy6vmai"))))
265       (build-system gnu-build-system)
266       (native-inputs
267        `(("idris" ,idris)))
268       (propagated-inputs
269        `(("idris-bifunctors" ,idris-bifunctors)))
270       (arguments (idris-default-arguments name))
271       (home-page "https://github.com/HuwCampbell/idris-lens")
272       (synopsis "Van Laarhoven lenses for Idris")
273       (description "Lenses are composable functional references.  They allow
274 accessing and modifying data within a structure.")
275       (license license:bsd-3))))