all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / Atom feed
* [bug#46124] [PATCH] Idris 2
@ 2021-01-27  5:43 raingloom
       [not found] ` <87r1j267c6.fsf@yoctocell.xyz>
  0 siblings, 1 reply; 8+ messages in thread
From: raingloom @ 2021-01-27  5:43 UTC (permalink / raw)
  To: 46124

Now that Idris 2 has had some proper tagged releases, I thought I'd
move it from my channel to Guix proper.
I've been using this package for quite a few months now and it pretty
much works. REPL works, building things works. Couldn't try IDE
functionality but I suppose it probably works if you can set it up in
Vim. That reminds me, I still haven't packaged the Vim mode, but I
don't use Vim so I don't really know its module system.

## Still TODO for the package:

search paths: There are no 3rd party Idris 2 modules yet, but it should
be done soon.

output prefix weirdness: Output is a bit odd, having an idris2-0.3.0
directory in its root, but since this is Guix, I suppose that's not
really a problem. Everything else is in its proper place, in bin, lib,
and share.

clang-toolchain support: Right now CC=gcc is hardcoded. Auto detection
would be preferable.

bootstrap: Right now it's bootstrapped from auto-generated Chez or
Racket. It **can** be built with Idris 1, but it uses such on obscene
amount of RAM that I refuse to consider building it that way ever
again. If someone wants to incorporate that step into Guix, they are
free to do so. Or we could generate it once and then freeze it and use
it as an input. Just leave my poor laptop out of it, it already
suffered enough. And probably leave the CI infrastructure out of it too.


## Bigger TODO:
Build system. Eventually it will need one.
Considering that it has multiple code generation backends, this is not
trivial, as each backend uses a different existing language, the
official ones (that I can remember right now) being:
* Chez
* Racket
* Gambit
* Chicken
* JavaScript/Node
* C

It might also make sense to compile Idris 2 itself with different
backends. It "officially" supports bootstrapping with Chez and Racket,
but others might be possible too.


Anyways, here's the patch, have fun with it, and/or suggest changes,
etc!




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
       [not found] ` <87r1j267c6.fsf@yoctocell.xyz>
@ 2021-04-26 15:22   ` raingloom
  2021-04-26 21:27     ` Maxime Devos
  0 siblings, 1 reply; 8+ messages in thread
From: raingloom @ 2021-04-26 15:22 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 46124

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

On Thu, 22 Apr 2021 10:39:53 +0200
Xinglu Chen <public@yoctocell.xyz> wrote:

> I think you forgot the attach the patch. ;)
> 

Ah heck. That might have been the case.
Here it is.

There hasn't been a tagged release since then, so I'm sending my
original patch, but I should note that in my channel I've been tracking
the latest commit, which does seem to work, although it's been a while
since I used Idris for anything complicated.

[-- Attachment #2: 0001-gnu-Added-Idris-2.patch --]
[-- Type: text/x-patch, Size: 4609 bytes --]

From 7554e53ad682e5baa40fee0776ab88cffc1a7772 Mon Sep 17 00:00:00 2001
From: raingloom <raingloom@riseup.net>
Date: Wed, 27 Jan 2021 06:21:01 +0100
Subject: [PATCH] gnu: Added Idris 2.

* gnu/packages/idris.scm (idris2): New variable.
---
 gnu/packages/idris.scm | 80 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/idris.scm b/gnu/packages/idris.scm
index ca2772b904..14de2762a1 100644
--- a/gnu/packages/idris.scm
+++ b/gnu/packages/idris.scm
@@ -21,6 +21,8 @@
 
 (define-module (gnu packages idris)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages chez)
   #:use-module (gnu packages haskell-check)
   #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages haskell-xyz)
@@ -28,12 +30,15 @@
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages sphinx)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
-  #:use-module (guix packages))
+  #:use-module (guix packages)
+  #:use-module (ice-9 regex))
 
 (define-public idris
   (package
@@ -150,6 +155,79 @@ can be specified precisely in the type.  The language is closely related to
 Epigram and Agda.")
     (license license:bsd-3)))
 
+(define-public idris2
+  (package
+    (name "idris2")
+    (version "0.3.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/idris-lang/Idris2")
+                    (commit (string-append "v" version))))
+              (sha256
+               (base32
+                "0sa2lpb7n6xqfknwld9rzm4bnb6qcd0ja1n63cnc5v8wdzr8q7kh"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ;; they are run as part of other targets
+       #:phases
+       (modify-phases
+           %standard-phases
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (substitute* "config.mk"
+               ((,(regexp-quote "PREFIX ?= $(HOME)/.idris2"))
+                (string-append "PREFIX = "
+                               (assoc-ref outputs "out"))))
+             (for-each
+              (lambda (f)
+                (substitute* f
+                  ((,(regexp-quote "#!/bin/sh"))
+                   (string-append "#!" (assoc-ref inputs "sh")
+                                  "/bin/sh"))))
+              (list "src/Compiler/Scheme/Chez.idr"
+                    "src/Compiler/Scheme/Racket.idr"
+                    "bootstrap/idris2_app/idris2.rkt"
+                    "bootstrap/idris2_app/idris2.ss"))))
+         ;; this is not the kind of bootstrap we want to run
+         (delete 'bootstrap)
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (invoke "make" "bootstrap"
+                     "SCHEME=scheme"
+                     ;; TODO detect toolchain
+                     "CC=gcc")))
+         (add-after 'build 'build-doc
+           (lambda _
+             (with-directory-excursion
+                 "docs"
+               (invoke "make" "html"))))
+         (add-after 'install 'install-doc
+           (lambda* (#:key outputs #:allow-other-keys)
+             (copy-recursively
+              "docs/build/html"
+              (string-append
+               (assoc-ref outputs "out")
+               "/share/doc/"
+               ,name "-" ,version)))))))
+    (inputs
+     `(("sh" ,bash-minimal)
+       ("chez-scheme" ,chez-scheme)))
+    (native-inputs
+     `(("python-sphinx" ,python-sphinx)
+       ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
+       ("python" ,python)))
+    (home-page "https://idris-lang.org/")
+    (synopsis "A dependently typed programming language, a successor to Idris")
+    (description
+     "Idris 2 is a general purpose language with dependent linear types.
+It is compiled, with eager evaluation.  Dependent types allow types to
+be predicated on values, meaning that some aspects of a program's behaviour
+can be specified precisely in the type.  It can use multiple languages as code
+generation backends.")
+    (license license:bsd-3)))
+
 ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
 (define (idris-default-arguments name)
   `(#:modules ((guix build gnu-build-system)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-04-26 15:22   ` raingloom
@ 2021-04-26 21:27     ` Maxime Devos
  2021-04-29 18:43       ` raingloom
  0 siblings, 1 reply; 8+ messages in thread
From: Maxime Devos @ 2021-04-26 21:27 UTC (permalink / raw)
  To: raingloom, Xinglu Chen; +Cc: 46124

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

raingloom schreef op ma 26-04-2021 om 17:22 [+0200]:
> There hasn't been a tagged release since then, so I'm sending my
> original patch, but I should note that in my channel I've been tracking
> the latest commit, which does seem to work, although it's been a while
> since I used Idris for anything complicated.
> 
> +                     ;; TODO detect toolchain
> +                     "CC=gcc")))

Unless idris has a compiler built in that uses gcc for compiling
idris to machine code, this should likely be
,(string-append "CC=" (cc-for-target)) instead, such that the
cross-compiler is used when cross-compiling.

Teaching (cc-for-target) to detect which toolchain should be used
is a separate matter.  Maybe it could be a macro that looks at
(package-native-inputs this-package) or something.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-04-26 21:27     ` Maxime Devos
@ 2021-04-29 18:43       ` raingloom
  2021-04-30  8:24         ` Xinglu Chen
  2021-04-30  8:50         ` Maxime Devos
  0 siblings, 2 replies; 8+ messages in thread
From: raingloom @ 2021-04-29 18:43 UTC (permalink / raw)
  To: Maxime Devos; +Cc: Xinglu Chen, 46124

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

On Mon, 26 Apr 2021 23:27:39 +0200
Maxime Devos <maximedevos@telenet.be> wrote:

> raingloom schreef op ma 26-04-2021 om 17:22 [+0200]:
> > There hasn't been a tagged release since then, so I'm sending my
> > original patch, but I should note that in my channel I've been
> > tracking the latest commit, which does seem to work, although it's
> > been a while since I used Idris for anything complicated.
> > 
> > +                     ;; TODO detect toolchain
> > +                     "CC=gcc")))  
> 
> Unless idris has a compiler built in that uses gcc for compiling
> idris to machine code, this should likely be
> ,(string-append "CC=" (cc-for-target)) instead, such that the
> cross-compiler is used when cross-compiling.
> 
> Teaching (cc-for-target) to detect which toolchain should be used
> is a separate matter.  Maybe it could be a macro that looks at
> (package-native-inputs this-package) or something.
> 
> Greetings,
> Maxime.

Oh, that's a leftover, I was using clang for a while, since it's
said to use less RAM. I switched back to gcc and left that in.

Here is the updated patch. No idea if this actually works cross
compiled, but I don't have much time to test it. My suspicion is that
it's likely broken and requires changes to Idris 2's code generators,
because they almost definitely call Chez, GCC, etc, with the wrong
arguments.

[-- Attachment #2: 0001-gnu-Added-Idris-2.patch --]
[-- Type: text/x-patch, Size: 4639 bytes --]

From e3c942454af34879393d073be755fa53390891bc Mon Sep 17 00:00:00 2001
From: raingloom <raingloom@riseup.net>
Date: Wed, 27 Jan 2021 06:21:01 +0100
Subject: [PATCH] gnu: Added Idris 2.

* gnu/packages/idris.scm (idris2): New variable.
---
 gnu/packages/idris.scm | 80 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/idris.scm b/gnu/packages/idris.scm
index ca2772b904..da66f7b0d8 100644
--- a/gnu/packages/idris.scm
+++ b/gnu/packages/idris.scm
@@ -21,6 +21,8 @@
 
 (define-module (gnu packages idris)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages chez)
   #:use-module (gnu packages haskell-check)
   #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages haskell-xyz)
@@ -28,12 +30,15 @@
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages sphinx)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
-  #:use-module (guix packages))
+  #:use-module (guix packages)
+  #:use-module (ice-9 regex))
 
 (define-public idris
   (package
@@ -150,6 +155,79 @@ can be specified precisely in the type.  The language is closely related to
 Epigram and Agda.")
     (license license:bsd-3)))
 
+(define-public idris2
+  (package
+    (name "idris2")
+    (version "0.3.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/idris-lang/Idris2")
+                    (commit (string-append "v" version))))
+              (sha256
+               (base32
+                "0sa2lpb7n6xqfknwld9rzm4bnb6qcd0ja1n63cnc5v8wdzr8q7kh"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ;; they are run as part of other targets
+       #:phases
+       (modify-phases
+           %standard-phases
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (substitute* "config.mk"
+               ((,(regexp-quote "PREFIX ?= $(HOME)/.idris2"))
+                (string-append "PREFIX = "
+                               (assoc-ref outputs "out"))))
+             (for-each
+              (lambda (f)
+                (substitute* f
+                  ((,(regexp-quote "#!/bin/sh"))
+                   (string-append "#!" (assoc-ref inputs "sh")
+                                  "/bin/sh"))))
+              (list "src/Compiler/Scheme/Chez.idr"
+                    "src/Compiler/Scheme/Racket.idr"
+                    "bootstrap/idris2_app/idris2.rkt"
+                    "bootstrap/idris2_app/idris2.ss"))))
+         ;; this is not the kind of bootstrap we want to run
+         (delete 'bootstrap)
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (invoke "make" "bootstrap"
+                     "SCHEME=scheme"
+                     ;; TODO detect toolchain
+                     ,(string-append "CC=" (cc-for-target)))))
+         (add-after 'build 'build-doc
+           (lambda _
+             (with-directory-excursion
+                 "docs"
+               (invoke "make" "html"))))
+         (add-after 'install 'install-doc
+           (lambda* (#:key outputs #:allow-other-keys)
+             (copy-recursively
+              "docs/build/html"
+              (string-append
+               (assoc-ref outputs "out")
+               "/share/doc/"
+               ,name "-" ,version)))))))
+    (inputs
+     `(("sh" ,bash-minimal)
+       ("chez-scheme" ,chez-scheme)))
+    (native-inputs
+     `(("python-sphinx" ,python-sphinx)
+       ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
+       ("python" ,python)))
+    (home-page "https://idris-lang.org/")
+    (synopsis "A dependently typed programming language, a successor to Idris")
+    (description
+     "Idris 2 is a general purpose language with dependent linear types.
+It is compiled, with eager evaluation.  Dependent types allow types to
+be predicated on values, meaning that some aspects of a program's behaviour
+can be specified precisely in the type.  It can use multiple languages as code
+generation backends.")
+    (license license:bsd-3)))
+
 ;; Idris modules use the gnu-build-system so that the IDRIS_LIBRARY_PATH is set.
 (define (idris-default-arguments name)
   `(#:modules ((guix build gnu-build-system)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-04-29 18:43       ` raingloom
@ 2021-04-30  8:24         ` Xinglu Chen
  2021-05-03  2:10           ` raingloom
  2021-04-30  8:50         ` Maxime Devos
  1 sibling, 1 reply; 8+ messages in thread
From: Xinglu Chen @ 2021-04-30  8:24 UTC (permalink / raw)
  To: raingloom, Maxime Devos; +Cc: 46124

On Thu, Apr 29 2021, raingloom wrote:

> Here is the updated patch. No idea if this actually works cross
> compiled, but I don't have much time to test it. My suspicion is that
> it's likely broken and requires changes to Idris 2's code generators,
> because they almost definitely call Chez, GCC, etc, with the wrong
> arguments.

I noticed that there is an ‘idris2_app’ directory in the ‘bin’ directory

  $ ls /gnu/store/va62hzp46c3dp2vlcnqc7fg109axj8rq-idris2-0.3.0/bin
  idris2*  idris2_app/

What is this used for?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-04-29 18:43       ` raingloom
  2021-04-30  8:24         ` Xinglu Chen
@ 2021-04-30  8:50         ` Maxime Devos
  1 sibling, 0 replies; 8+ messages in thread
From: Maxime Devos @ 2021-04-30  8:50 UTC (permalink / raw)
  To: raingloom; +Cc: Xinglu Chen, 46124

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

raingloom schreef op do 29-04-2021 om 20:43 [+0200]:
> On Mon, 26 Apr 2021 23:27:39 +0200
> Maxime Devos <maximedevos@telenet.be> wrote:
> 
> > raingloom schreef op ma 26-04-2021 om 17:22 [+0200]:
> > > [...]
> > > 
> > > +                     ;; TODO detect toolchain
> > > +                     "CC=gcc")))  
> > 
> > Unless idris has a compiler built in that uses gcc for compiling
> > idris to machine code, this should likely be
> > ,(string-append "CC=" (cc-for-target)) instead, such that the
> > cross-compiler is used when cross-compiling.
> > 
> > [...]
> Oh, that's a leftover, I was using clang for a while, since it's
> said to use less RAM. I switched back to gcc and left that in.
> 
> Here is the updated patch. No idea if this actually works cross
> compiled, but I don't have much time to test it.

IIUC, cross-compilation is not required to be supported by each
package in guix. It is something nice-to-have, but not strictly
required.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-04-30  8:24         ` Xinglu Chen
@ 2021-05-03  2:10           ` raingloom
  2021-05-04 17:12             ` Xinglu Chen
  0 siblings, 1 reply; 8+ messages in thread
From: raingloom @ 2021-05-03  2:10 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: Maxime Devos, 46124

On Fri, 30 Apr 2021 10:24:42 +0200
Xinglu Chen <public@yoctocell.xyz> wrote:

> On Thu, Apr 29 2021, raingloom wrote:
> 
> > Here is the updated patch. No idea if this actually works cross
> > compiled, but I don't have much time to test it. My suspicion is
> > that it's likely broken and requires changes to Idris 2's code
> > generators, because they almost definitely call Chez, GCC, etc,
> > with the wrong arguments.  
> 
> I noticed that there is an ‘idris2_app’ directory in the ‘bin’
> directory
> 
>   $ ls /gnu/store/va62hzp46c3dp2vlcnqc7fg109axj8rq-idris2-0.3.0/bin
>   idris2*  idris2_app/
> 
> What is this used for?
> 

If you take a look at $(guix build idris2)/bin/idris2, it's actually
just a wrapper. It contains the supporting dynamically linked shared
objects and the executable itself.

I don't know the details of what each file does or why it's like this,
the codegen seems to use a similar structure for all backends. The
scheme files are probably all for the Chez backend, the shared objects
are either C libraries (for socket support and stuff), or compiled Chez
code. I just noticed the Racket script, that I have no idea about.

Idris 2's build system makes some... uhm... interesting choices, so
it's entirely possible that not all of those are necessary, or could be
moved somewhere more sensible.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#46124] [PATCH] Idris 2
  2021-05-03  2:10           ` raingloom
@ 2021-05-04 17:12             ` Xinglu Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Xinglu Chen @ 2021-05-04 17:12 UTC (permalink / raw)
  To: raingloom; +Cc: Maxime Devos, 46124

On Mon, May 03 2021, raingloom wrote:

> On Fri, 30 Apr 2021 10:24:42 +0200
> Xinglu Chen <public@yoctocell.xyz> wrote:
>
>> On Thu, Apr 29 2021, raingloom wrote:
>> 
>> > Here is the updated patch. No idea if this actually works cross
>> > compiled, but I don't have much time to test it. My suspicion is
>> > that it's likely broken and requires changes to Idris 2's code
>> > generators, because they almost definitely call Chez, GCC, etc,
>> > with the wrong arguments.  
>> 
>> I noticed that there is an ‘idris2_app’ directory in the ‘bin’
>> directory
>> 
>>   $ ls /gnu/store/va62hzp46c3dp2vlcnqc7fg109axj8rq-idris2-0.3.0/bin
>>   idris2*  idris2_app/
>> 
>> What is this used for?
>
> If you take a look at $(guix build idris2)/bin/idris2, it's actually
> just a wrapper. It contains the supporting dynamically linked shared
> objects and the executable itself.
>
> I don't know the details of what each file does or why it's like this,
> the codegen seems to use a similar structure for all backends. The
> scheme files are probably all for the Chez backend, the shared objects
> are either C libraries (for socket support and stuff), or compiled Chez
> code. I just noticed the Racket script, that I have no idea about.
>
> Idris 2's build system makes some... uhm... interesting choices, so
> it's entirely possible that not all of those are necessary, or could be
> moved somewhere more sensible.

Looking at the Nix package, they remove the wrapper and instead move
bin/idris2_app/idris2.so to bin/idris2 and wraps that executable[1].
Perhaps we could do the same thing?  I am not familiar with Idris,
though.

[1]: https://github.com/nixos/nixpkgs/blob//pkgs/development/compilers/idris2/default.nix#L41




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-04 17:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27  5:43 [bug#46124] [PATCH] Idris 2 raingloom
     [not found] ` <87r1j267c6.fsf@yoctocell.xyz>
2021-04-26 15:22   ` raingloom
2021-04-26 21:27     ` Maxime Devos
2021-04-29 18:43       ` raingloom
2021-04-30  8:24         ` Xinglu Chen
2021-05-03  2:10           ` raingloom
2021-05-04 17:12             ` Xinglu Chen
2021-04-30  8:50         ` Maxime Devos

all messages for Guix-related lists mirrored at yhetil.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix

Example config snippet for mirrors.


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git