gnu: Add idris-wl-pprint.
[jackhill/guix/guix.git] / gnu / packages / idris.scm
CommitLineData
ae482ce1
DC
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;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages idris)
21 #:use-module (gnu packages haskell)
22 #:use-module (gnu packages multiprecision)
23 #:use-module (gnu packages ncurses)
ea3b38f1 24 #:use-module (guix build-system gnu)
ae482ce1 25 #:use-module (guix build-system haskell)
ae482ce1
DC
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages))
30
31(define-public idris
32 (package
33 (name "idris")
34 (version "0.99")
35 (source (origin
36 (method url-fetch)
37 (uri (string-append
38 "https://hackage.haskell.org/package/"
39 "idris-" version "/idris-" version ".tar.gz"))
40 (sha256
41 (base32
42 "1sd4vy5rx0mp32xj99qijhknkgw4d2rxvz6wiy3pym6kaqmc497i"))))
43 (build-system haskell-build-system)
44 (inputs
45 `(("gmp" ,gmp)
46 ("ncurses" ,ncurses)
47 ("ghc-aeson" ,ghc-aeson)
48 ("ghc-async" ,ghc-async)
49 ("ghc-annotated-wl-pprint" ,ghc-annotated-wl-pprint)
50 ("ghc-ansi-terminal" ,ghc-ansi-terminal)
51 ("ghc-ansi-wl-pprint" ,ghc-ansi-wl-pprint)
52 ("ghc-base64-bytestring" ,ghc-base64-bytestring)
53 ("ghc-blaze-html" ,ghc-blaze-html)
54 ("ghc-blaze-markup" ,ghc-blaze-markup)
55 ("ghc-cheapskate" ,ghc-cheapskate)
56 ("ghc-fingertree" ,ghc-fingertree)
57 ("ghc-fsnotify" ,ghc-fsnotify)
58 ("ghc-ieee754" ,ghc-ieee754)
59 ("ghc-mtl" ,ghc-mtl)
60 ("ghc-network" ,ghc-network)
61 ("ghc-optparse-applicative" ,ghc-optparse-applicative)
62 ("ghc-parsers" ,ghc-parsers)
63 ("ghc-regex-tdfa" ,ghc-regex-tdfa)
64 ("ghc-safe" ,ghc-safe)
65 ("ghc-split" ,ghc-split)
66 ("ghc-tasty" ,ghc-tasty)
67 ("ghc-tasty-golden" ,ghc-tasty-golden)
68 ("ghc-tasty-rerun" ,ghc-tasty-rerun)
69 ("ghc-terminal-size" ,ghc-terminal-size)
70 ("ghc-text" ,ghc-text)
71 ("ghc-trifecta" ,ghc-trifecta)
72 ("ghc-uniplate" ,ghc-uniplate)
73 ("ghc-unordered-containers" ,ghc-unordered-containers)
74 ("ghc-utf8-string" ,ghc-utf8-string)
75 ("ghc-vector-binary-instances" ,ghc-vector-binary-instances)
76 ("ghc-vector" ,ghc-vector)
77 ("ghc-zip-archive" ,ghc-zip-archive)
78 ("ghc-zlib" ,ghc-zlib)))
79 (arguments
80 `(#:tests? #f ; FIXME: Test suite doesn't run in a sandbox.
81 #:configure-flags
82 (list (string-append "--datasubdir="
83 (assoc-ref %outputs "out") "/lib/idris"))
84 #:phases
85 (modify-phases %standard-phases
86 (add-before 'configure 'set-cc-command
87 (lambda _
88 (setenv "CC" "gcc")
89 #t))
90 (add-after 'install 'fix-libs-install-location
91 (lambda* (#:key outputs #:allow-other-keys)
92 (let* ((out (assoc-ref outputs "out"))
93 (lib (string-append out "/lib/idris"))
94 (modules (string-append lib "/libs")))
95 (for-each
96 (lambda (module)
97 (symlink (string-append modules "/" module)
98 (string-append lib "/" module)))
99 '("prelude" "base" "contrib" "effects" "pruviloj"))))))))
100 (native-search-paths
101 (list (search-path-specification
102 (variable "IDRIS_LIBRARY_PATH")
103 (files '("lib/idris")))))
104 (home-page "http://www.idris-lang.org")
105 (synopsis "General purpose language with full dependent types")
106 (description "Idris is a general purpose language with full dependent
107types. It is compiled, with eager evaluation. Dependent types allow types to
108be predicated on values, meaning that some aspects of a program's behaviour
109can be specified precisely in the type. The language is closely related to
110Epigram and Agda.")
111 (license license:bsd-3)))
ea3b38f1
DC
112
113;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
114(define (idris-default-arguments name)
115 `(#:modules ((guix build gnu-build-system)
116 (guix build utils)
117 (ice-9 ftw)
118 (ice-9 match))
119 #:phases
120 (modify-phases %standard-phases
121 (delete 'configure)
122 (delete 'build)
123 (delete 'check)
124 (replace 'install
125 (lambda* (#:key inputs outputs #:allow-other-keys)
126 (let* ((out (assoc-ref outputs "out"))
127 (idris (assoc-ref inputs "idris"))
128 (idris-bin (string-append idris "/bin/idris"))
129 (idris-libs (string-append idris "/lib/idris/libs"))
130 (module-name (and (string-prefix? "idris-" ,name)
131 (substring ,name 6)))
132 (ibcsubdir (string-append out "/lib/idris/" module-name))
133 (ipkg (string-append module-name ".ipkg"))
134 (idris-library-path (getenv "IDRIS_LIBRARY_PATH"))
135 (idris-path (string-split idris-library-path #\:))
136 (idris-path-files (apply append
137 (map (lambda (path)
138 (map (lambda (dir)
139 (string-append path "/" dir))
140 (scandir path))) idris-path)))
141 (idris-path-subdirs (filter (lambda (path)
142 (and path (match (stat:type (stat path))
143 ('directory #t)
144 (_ #f))))
145 idris-path-files))
146 (install-cmd (cons* idris-bin
147 "--ibcsubdir" ibcsubdir
148 "--install" ipkg
149 (apply append (map (lambda (path)
150 (list "--idrispath"
151 path))
152 idris-path-subdirs)))))
153 (setenv "IDRIS_LIBRARY_PATH" idris-libs)
154 ;; FIXME: Seems to be a bug in idris that causes a dubious failure.
155 (apply system* install-cmd)
156 #t))))))
157
158(define-public idris-lightyear
159 (let ((commit "6d65ad111b4bed2bc131396f8385528fc6b3678a"))
160 (package
161 (name "idris-lightyear")
162 (version (git-version "0.1" "1" commit))
163 (source (origin
164 (method git-fetch)
165 (uri (git-reference
166 (url "https://github.com/ziman/lightyear")
167 (commit commit)))
168 (file-name (git-file-name name version))
169 (sha256
170 (base32
171 "1pkxnn3ryr0v0cin4nasw7kgkc9dnnpja1nfbj466mf3qv5s98af"))))
172 (build-system gnu-build-system)
173 (native-inputs
174 `(("idris" ,idris)))
175 (arguments (idris-default-arguments name))
176 (home-page "https://github.com/ziman/lightyear")
177 (synopsis "Lightweight parser combinator library for Idris")
178 (description "Lightweight parser combinator library for Idris, inspired
179by Parsec. This package is used (almost) the same way as Parsec, except for one
180difference: backtracking.")
181 (license license:bsd-2))))
4e17fff3
DC
182
183(define-public idris-wl-pprint
184 (let ((commit "1d365fcf4ba075859844dbc5eb96a90f57b9f338"))
185 (package
186 (name "idris-wl-pprint")
187 (version (git-version "0.1" "1" commit))
188 (source (origin
189 (method git-fetch)
190 (uri (git-reference
191 (url "https://github.com/shayan-najd/wl-pprint")
192 (commit commit)))
193 (file-name (git-file-name name version))
194 (sha256
195 (base32
196 "0g7c3y9smifdz4sivi3qmvymhdr7v9kfq45fmfmmvkqcrix0spzn"))))
197 (build-system gnu-build-system)
198 (native-inputs
199 `(("idris" ,idris)))
200 (arguments (idris-default-arguments name))
201 (home-page "https://github.com/shayan-najd/wl-pprint")
202 (synopsis "Pretty printing library")
203 (description "A pretty printing library for Idris based on Phil Wadler's
204paper A Prettier Printer and on Daan Leijen's extensions in the Haskell
205wl-pprint library.")
206 (license license:bsd-2))))