profile
viewpoint

eholk/harlan 1127

A language for GPU computing.

brson/mir2wasm 201

An experimental compiler from Rust to WebAssembly (inactive - do not use)

eholk/Boot2Rust 196

EFI applications in Rust

eholk/elegant-weapons 103

An R6RS framework for creating compilers that target C.

eholk/bench-dot-product 10

Several variations of a dot product benchmark.

eholk/Arduino-Pong 8

A simple Pong game for the Arduino which uses one of the OLED displays from Adafruit.

eholk/llvm 4

Temporary fork of LLVM for Rust

eholk/coq-stlc 2

Proof of type safety for Simply Typed Lambda Calculus in Coq.

eholk/hexlife 2

Conway's Game of Life on a hexagonal grid.

issue closedeholk/rust-stl

Triangles can't be used in any way

Since nothing is public, the triangles can't be used in any way by someone who is using this crate.

closed time in 2 months

CryZe

issue commenteholk/rust-stl

Triangles can't be used in any way

Good call! I'll go ahead and mark this closed.

CryZe

comment created time in 2 months

delete branch eholk/schism

delete branch : library-files

delete time in 2 months

push eventgoogle/schism

Eric Holk

commit sha c6eda3de2c5637063f9bdd8cfb77753f7f9990e5

Add %file-exists? runtime predicate

view details

Eric Holk

commit sha 63e7117e03078a4683309f27f95fabd88eec8824

Add %string-append runtime function

view details

Eric Holk

commit sha 36cabd28cc31914b1a06df10f838c76a0772dd3c

Update snapshot

view details

Eric Holk

commit sha e81438d04126d4d635f8c20afddfd10ef12741cb

Add string-append

view details

Eric Holk

commit sha ceb64bfa88903923dff670b5fcb217e2d195c8e3

Search for library files This removes the hardcoded list of libraries in favor of searching the file system for them. This makes adding new libraries as easy as making a new file. Fixes #19.

view details

Eric Holk

commit sha 8daae2d894bf6503a49e67269b98d35af1c7e653

Adding string hack

view details

Eric Holk

commit sha 48d9df21bff07080d93cd58336bc66cbe92705ce

Merge pull request #101 from eholk/library-files Search filesystem for libraries

view details

push time in 2 months

issue closedgoogle/schism

Allow importing libraries from other files

Right now the library system isn't really a library system. The compiler just pastes the code for a subset of rnrs into every library we compiler. It would be better to be able to load libraries from files, and do proper lexical scoping between the modules.

Eventually it would be great to have dynamic loading of modules, so there could be one rnrs.wasm that is loaded by all Schism libraries. For the time being, inlining everything into one big Wasm module would be a good start though.

closed time in 2 months

eholk

PR merged google/schism

Search filesystem for libraries

Removes the hardcoded list of libraries from before and instead searches a few library paths.

To do this, I added a %file-exists? runtime function, and string-append to do the path computations. Adding these required another compiler snapshot.

+78 -27

1 comment

7 changed files

eholk

pr closed time in 2 months

Pull request review commentgoogle/schism

Search filesystem for libraries

   (define (read-library-from-file filename)     (%open-as-stdin filename)     (read))-  ++  (define (find-library-file name)+    (let ((search-paths '("./test/lib"+                          "./lib"+                          "./scheme-lib"))+          (path-suffix (string-append+                        (fold-left (lambda (path part)+                                     (string-append+                                      path+                                      (string-append "/" (symbol->string part))))+                                   ""+                                   name)+                        ".ss")))+      (fold-left (lambda (found base-path)

Good idea! I think I'll save this for a future cleanup though.

eholk

comment created time in 2 months

Pull request review commentgoogle/schism

Search filesystem for libraries

 function rt(engine) {         '%string->symbol': value => 'S' + value,         '%symbol->string': x => x.substring(1), +        '%string-append': (x, y) => 's' + x.substring(1) + y.substring(1),

Good catch. Done.

eholk

comment created time in 2 months

push eventeholk/schism

Eric Holk

commit sha 8daae2d894bf6503a49e67269b98d35af1c7e653

Adding string hack

view details

push time in 2 months

create barnchgoogle/schism

branch : library-files

created branch time in 2 months

pull request commentgoogle/schism

Search filesystem for libraries

Had to force push because of snapshot updates from #98. (There really needs to be a better way to manage snapshot changes.)

eholk

comment created time in 3 months

push eventeholk/schism

jitwit

commit sha a14cdaeb67b603f7c21ec022ab54f4951f6470fd

fix string eq?

view details

jitwit

commit sha 7e5adbeea7e2f3c48d845c8d0035fc66a6cf6408

update snapshot (%string=?)

view details

jitwit

commit sha 2180857970180509f46eccac1c1ae9a6a47599d1

distinguish strings created from symbol->string

view details

Eric Holk

commit sha 2aa18f0c172aa4c91d4e4c18dc78fdba3f3e55e3

Merge pull request #98 from jitwit/strings fix eq? for strings

view details

Eric Holk

commit sha c6eda3de2c5637063f9bdd8cfb77753f7f9990e5

Add %file-exists? runtime predicate

view details

Eric Holk

commit sha 63e7117e03078a4683309f27f95fabd88eec8824

Add %string-append runtime function

view details

Eric Holk

commit sha 36cabd28cc31914b1a06df10f838c76a0772dd3c

Update snapshot

view details

Eric Holk

commit sha e81438d04126d4d635f8c20afddfd10ef12741cb

Add string-append

view details

Eric Holk

commit sha ceb64bfa88903923dff670b5fcb217e2d195c8e3

Search for library files This removes the hardcoded list of libraries in favor of searching the file system for them. This makes adding new libraries as easy as making a new file. Fixes #19.

view details

push time in 3 months

issue openedgoogle/schism

Do we want a SchismValue or similar class?

This came up in the discussions around #97 and #98. Right now we are generally representing Schism objects as JavaScript objects. So far this has worked well. The code is fast, and it makes JavaScript interop easy.

But, there may be a reason to distinguish these. One way would be to have a SchismValue class that includes a field saying what type it is, and then whatever data is represented.

Another option is to have a zoo of types, like SchismPair, SchismString, SchismNumber, etc. At first glance, I'm less fond of this, but I haven't thought real hard about it.

Anyway, what are the pros and cons? Is anything broken with the status quo, or would wrapping everything in SchismValue just complicate things for no real benefit?

created time in 3 months

issue closedgoogle/schism

Add test case for string `eq?` behavior

Strings should have the following equality behavior:

> (eq? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#f
> (string=? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#t

Because strings are represented as JavaScript objects, we might be accidentally getting value equality instead of reference equality for eq? on strings. We should add a test case to make sure we have the right behavior, and fix it if we don't.

closed time in 3 months

eholk

issue commentgoogle/schism

Add test case for string `eq?` behavior

Fixed in #98.

eholk

comment created time in 3 months

push eventgoogle/schism

jitwit

commit sha a14cdaeb67b603f7c21ec022ab54f4951f6470fd

fix string eq?

view details

jitwit

commit sha 7e5adbeea7e2f3c48d845c8d0035fc66a6cf6408

update snapshot (%string=?)

view details

jitwit

commit sha 2180857970180509f46eccac1c1ae9a6a47599d1

distinguish strings created from symbol->string

view details

Eric Holk

commit sha 2aa18f0c172aa4c91d4e4c18dc78fdba3f3e55e3

Merge pull request #98 from jitwit/strings fix eq? for strings

view details

push time in 3 months

PR merged google/schism

fix eq? for strings

I think this fixes the reference/value equality issue for strings (#97).

  • added%string=? to rt.mjs which uses String.valueOf() when checking for equality.
  • %string=? is used by string=? and has been added to runtime-imports and effect-free-callee?

Would it be better to write string=? in pure scheme? I was also wondering about how functions like string-length and string-ref should be added.

+35 -6

2 comments

5 changed files

jitwit

pr closed time in 3 months

pull request commentgoogle/schism

fix eq? for strings

Thanks for the info, @awwx.

It would potentially make sense to fold all of Schism's values into a SchismValue class, or something like that, rather than using bare JavaScript types. There are pros and cons though. There's something nice about Schism values being interoperable with JS with no wrapping or unwrapping. It's a discussion that's probably worth having.

For now, I think this PR is in a good state, so I'm going to go ahead and merge it. We may want to iterate some more on this, but I think this is a good step for now.

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

fix eq? for strings

 function rt(engine) {         // that's not specified on the Scheme language level.  Using JS         // strings for symbols allows us to compare with ===, as is         // required.-        'string?': x => typeof(x) === 'string' && x.charAt(0) === 's',+        'string?': x => x instanceof String && x.charAt(0) === 's',

I just ran my benchmark again, although on a different computer this time. The average of 9 runs with this change was 1.117 s versus 1.138 s without. So, perhaps slight improvement, but likely just within the noise. I think we're at performance parity now.

Thanks for sticking with this!

jitwit

comment created time in 3 months

push eventeholk/schism

Eric Holk

commit sha 4305a8d7298739ae06a4008880837a0748f77d92

Fix test copyright date

view details

push time in 3 months

PR opened google/schism

Reviewers
Search filesystem for libraries

Removes the hardcoded list of libraries from before and instead searches a few library paths.

To do this, I added a %file-exists? runtime function, and string-append to do the path computations. Adding these required another compiler snapshot.

+78 -27

0 comment

7 changed files

pr created time in 3 months

create barncheholk/schism

branch : library-files

created branch time in 3 months

Pull request review commentgoogle/schism

fix eq? for strings

 function rt(engine) {         // that's not specified on the Scheme language level.  Using JS         // strings for symbols allows us to compare with ===, as is         // required.-        'string?': x => typeof(x) === 'string' && x.charAt(0) === 's',+        'string?': x => x instanceof String && x.charAt(0) === 's',

It seems like what we'd have to do is wrap Schism strings in a JavaScript object to make === do the right thing.

It's kind of bizarre to me that JavaScript doesn't have a reference equality operator. Or, maybe it does for objects but strings aren't considered objects. Maybe the idea is that strings are values like integers are.

jitwit

comment created time in 3 months

issue closedgoogle/schism

More efficient string representation

Strings right now are represented as lists of characters with a different tag. This is inefficient. We should use a better representation, such as a vector of characters. This should help some with #32.

closed time in 3 months

eholk

issue commentgoogle/schism

More efficient string representation

This is fixed now that all of our data are JavaScript objects.

eholk

comment created time in 3 months

pull request commentgoogle/schism

Update introduction in README (#93)

@AMDphreak - Do you want to double check this before I merge it?

eholk

comment created time in 3 months

PR opened google/schism

Update introduction in README (#93)

We discussed how to improve the first sentence on #93, but I never made the change. This PR fixes that.

+5 -2

0 comment

1 changed file

pr created time in 3 months

create barncheholk/schism

branch : update-readme

created branch time in 3 months

issue commentgoogle/schism

Add some kind of `include-data` macro

Another option would be to have some way to embed a virtual filesystem in a custom section at the end of the .wasm file. I think this is likely to be more work, but it feels more correct in some ways.

eholk

comment created time in 3 months

issue openedgoogle/schism

Add some kind of `include-data` macro

With factoring rnrs into a separate file (#90), we've lost the nice property that Schism can run from just schism.wasm.

One easy way to get this functionality back would be to add an include-data macro, that would work something like this:

(include-data "filename")

At compile time, we'd read a datum from the file with the given name and include it as a quoted literal. If "filename" contained (1 2 3), then (include-data "filename") would expand to '(1 2 3).

created time in 3 months

issue commentgoogle/schism

Add test case for string `eq?` behavior

Thanks for the clarifications!

You make a compelling case for being willing to break from the standards as it makes sense. I haven't closely followed the standards process, but I gather that R6RS was contentious, and R7RS-large seems unlikely to finish.

There may not be much reason to do this, but I don't think making list->string create a new object necessitates also supporting mutable strings. For example, I might want some kind of unique tag that I can test with eq?, but not want to use gensym for some reason.

I have "list->string makes a new string" pretty firmly embedded in my mental model for Scheme, so my vote would still be to keep that.

I haven't really had any use for mutable strings yet in Schism, or other Scheme implementations that I can think of, so I think it makes sense to hold off on adding them until there's a clear use, if ever. If Schism gets some kind of custom data type support in the future, we might be fine to just add a mutable string library that defines its own parallel string type.

eholk

comment created time in 3 months

Pull request review commentgoogle/schism

fix eq? for strings

 function rt(engine) {         // that's not specified on the Scheme language level.  Using JS         // strings for symbols allows us to compare with ===, as is         // required.-        'string?': x => typeof(x) === 'string' && x.charAt(0) === 's',+        'string?': x => x instanceof String && x.charAt(0) === 's',

I just ran 9 runs of benchmark-compiler.sh on the current master and this change, and averaged the results for the stage3 compile.

Master: 0.684 seconds This PR: 0.706 seconds

So, this version is about 3% slower (with all the caveats around whether compiling the compiler is a good benchmark; if I recall correctly, Schism doesn't a lot of string comparison, but maybe those are just leftover memories from my horrible initial implementation of symbols).

It's not a small regression, and I'm willing to take it for correctness, but it's the kind of thing that could add up over time. Maybe we can do this in a way that has equivalent performance?

jitwit

comment created time in 3 months

issue commentgoogle/schism

Add test case for string `eq?` behavior

Ah, fair question. As a default answer, I'd say we should err on the side of complying with a Scheme standard. So far I've been roughly following R6RS, but maybe it's worth following R7RS instead. Or, given how long R7RS Large seems to be taking, maybe we should feel free to break from the standard and just be our own dialect. Regardless, does R6RS require the behavior that two strings created by list->string are not eq??

What are your reasons against mutable strings?

eholk

comment created time in 3 months

Pull request review commentgoogle/schism

fix eq? for strings

 function rt(engine) {         // that's not specified on the Scheme language level.  Using JS         // strings for symbols allows us to compare with ===, as is         // required.-        'string?': x => typeof(x) === 'string' && x.charAt(0) === 's',+        'string?': x => x instanceof String && x.charAt(0) === 's',

This looks like it's getting into subtleties of JavaScript that I'm not as familiar with. What's the difference here between typeof(x) === 'string' and x instanceof String?

jitwit

comment created time in 3 months

pull request commentgoogle/schism

list->string fix null lists & add list? predicate

Thanks for confirming! I guess that's something to follow up with on #97.

jitwit

comment created time in 3 months

push eventgoogle/schism

jitwit

commit sha 40cb4a2569aee37f15c185e48842ad6a4646dd91

list->string fix null lists & add list? predicate & tests

view details

jitwit

commit sha fd707fdfb38cbb722248021e725ca5f70480ea6c

update snapshot (list->string)

view details

Eric Holk

commit sha b5b7c1db4d34b7decd1626a5ffdbb0fc5909c7b6

Merge pull request #96 from jitwit/list-to-string list->string fix null lists & add list? predicate

view details

push time in 3 months

PR merged google/schism

list->string fix null lists & add list? predicate

I noticed that list->string raised an error if passed '(). I considered changing the predicate to check for pair? or null? but thought it might make more sense to implement a proper list? procedure. list? uses tortoise-hair cycle detection to check for improper lists.

Also, is it reasonable to change string=? to use eq?? string=? was converting to lists of chars and calling list-all-eq?. I thought this change might be reasonable because of the current string representation and that eq? uses ===. If no, what would a better way to replace list-all-eq? be?

+90 -6

3 comments

5 changed files

jitwit

pr closed time in 3 months

pull request commentgoogle/schism

list->string fix null lists & add list? predicate

Actually, maybe I'm wrong about the eq? thing. It depends on whether the runtime is comparing strings as objects or as strings, I guess. I opened #97 so we can add test coverage to make sure we have the right behavior and fix it if we don't.

jitwit

comment created time in 3 months

issue openedgoogle/schism

Add test case for string `eq?` behavior

Strings should have the following equality behavior:

> (eq? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#f
> (string=? (list->string '(#\a #\b)) (list->string '(#\a #\b)))
#t

Because strings are represented as JavaScript objects, we might be accidentally getting value equality instead of reference equality for eq? on strings. We should add a test case to make sure we have the right behavior, and fix it if we don't.

created time in 3 months

pull request commentgoogle/schism

list->string fix null lists & add list? predicate

Looks good to me!

Using eq? in string=? looks okay to me, since like you said, it's implemented with JavaScript's === under the hood. Although, I think this might mean we have a bug in eq? since (eq? (list->string '(#\a #\b)) (list->string '(#\a #\b))) should be #f, while (string=? (list->string '(#\a #\b)) (list->string '(#\a #\b))) should be #t.

To get the tests to pass, this needs a new snapshot. You can make one by doing ./mksnapshot.sh and committing the results. Please do this as a commit by itself, so that it's easy to verify that the snapshot was generated exactly from the previously committed code. Or, I can make the snapshot for you.

jitwit

comment created time in 3 months

push eventgoogle/schism

jitwit

commit sha 9a6dc724e1c0cdbbeb7b7b7d0217a0f408144ff4

display negative numbers

view details

Eric Holk

commit sha 162f177ebc51d1d86098b5b3cd55212599351622

Merge pull request #95 from jitwit/negatives display negative numbers

view details

push time in 3 months

PR merged google/schism

display negative numbers

Negative numbers were not displaying properly. For example (display -123) would print out /.-.

+5 -3

0 comment

1 changed file

jitwit

pr closed time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

+;; Copyright 2019 Google LLC+;;+;; Licensed under the Apache License, Version 2.0 (the License);+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;;     http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an AS IS BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++(library+    (trivial)+  (export do-test)+  (import (rnrs))++  ;;; The uKanren paper uses vectors to wrap variables. For now, we+  ;;; tag pairs.+  (define (var name)+    `(var . ,name))++  (define (var? x)+    (and (pair? x) (eq? 'var (car x))))++  (define (var=? x y)+    (eq? (cdr x) (cdr y)))++  ;;;; Unification+  ;;; lookup is referred to as walk in the uKanren paper. The name+  ;;; lookup is used in sokuza-karen.+  (define (lookup var s)+    (let ((binding (and (var? var) (assp (lambda (u) (var=? u var)) s))))+      (if binding (lookup (cdr binding) s) var)))++  ;;; A more diligent lookup.+  (define (lookup* var s)+    (let ((v (lookup var s)))+      (cond+       ((var? v) v)+       ((pair? v) (cons (lookup* (car v) s) (lookup* (cdr v) s)))+       (else v))))++  (define (extend-s var val s)+    `((,var . ,val) . ,s))++  (define (unify u v s)+    (let ((u (lookup u s)) (v (lookup v s)))+      (cond+       ((var? u) (extend-s u v s))+       ((var? v) (extend-s v u s))+       ((and (pair? u) (pair? v))+        (let ((s (unify (car u) (car v) s)))+          (and s (unify (cdr u) (cdr v) s))))+       (else (and (eq? u v) s)))))++  ;;;; Core+  ;;; uKanren paper refers to these as unit and mzero.+  (define (succeed s.c) `(,s.c))+  (define (fail s.c) '())++  (define (== u v)+    (lambda (s.c)+      (lambda ()+        (let ((s (unify u v (car s.c))))+          (if s (succeed `(,s . ,(cdr s.c))) (fail s))))))++  ;;; Use int c in s.c pair to introduce a new variable to give to f+  ;;; to build a goal.

Would the stateful procedure essentially be doing a gensym? I'd be a little concerned about adding too much state, because some of the elegance of uKanren is it's purely functional manner. Although, using state under the covers would make sense if we wanted to build this up to a full scale logic programming system.

I think adding substitution+constant in a comment wouldn't hurt. As far as names go though, I don't mind the short one. Out of curiosity, @jitwit, was there a problem parsing s/c, which I think is what the paper used? If so, we probably have a reader bug.

jitwit

comment created time in 3 months

push eventgoogle/schism

jitwit

commit sha a0d81023f65483c0313935924d275c71af44d9ba

experiment with u-kanren

view details

jitwit

commit sha 3f78963fe6ae92dba18777560119d9b5ebdb7be0

more ukanren -- conso/appendo

view details

jitwit

commit sha 99205a039aeb003c1ce857af5cac1d5ed6da6153

add test for assp

view details

jitwit

commit sha a61768a02cc6de6aacf1991d1d4b7caf515600c0

real tests instead of printing out & minor clean

view details

jitwit

commit sha edcb0127a6fb7cbd6438b2fa26b0162d3b7a2b03

more relations goals & comments

view details

Eric Holk

commit sha 6477c24fd98afcd487f1872eb862b69334fa2390

Merge pull request #94 from jitwit/micro-kanren experiment with u-kanren

view details

push time in 3 months

PR merged google/schism

experiment with u-kanren

Hey! I thought it would be fun to take a stab at adding micro-kanren (#81) .

I ended up using assp and equal? for the implementation, which I added to rnrs.ss. I gather that the equal? is improper since it doesn't do cyclic inputs, which I'm guessing is what's wanted?

Anyhow, the actual test cases I added were based on stuff in the linked paper. Are there other examples that should be there?

+375 -2

2 comments

3 changed files

jitwit

pr closed time in 3 months

pull request commentgoogle/schism

experiment with u-kanren

I'll go ahead and merge this PR. Thank you so much for the contribution!

Feel free to submit another PR if you want to incorporate any of @amirouche's suggestions.

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

               (lambda (tl)                 (call/fresh                  (lambda (z*)-                   (conj (conso hd tl x)-                         (conj (conso hd z* z)-                               (appendo tl y z*)))))))))))-+                   (conj*+                    `(,(conso hd tl x)+                      ,(conso hd z* z)+                      ,(appendo tl y z*))))))))))) +  (define (display-ln x)+    (display x) (newline))+     (define (do-test)     (let ((empty-state '(() . 0))           (vx (var 'x))           (vy (var 'y))-          (vz (var 'z)))-      (and (equal? '(1 2)-                   (run* 2 vx (choice vx '(1 2 3))))+          (vz (var 'z))+          (vq (var 'q)))+      (and (equal? '(1 2 3)+                   (run* vx (element-of vx '(1 2 3))))+           (equal? '()+                   (run* vx (conj* `(,(== vx 6)+                                     ,(== vx vy)+                                     ,(== vy 5)))))            (equal? '(0 1 2 3 4)-                   (run* 5 vy (conj (== vy vx) (natural vx))))+                   (run 5 vy (conj (== vy vx)+                                   (natural vx))))            (equal? '()-                   (run* 2 vx (conj (choice vx '(1 2 3)) (== vx 0))))-           (equal? '((() (0 1 2)) ((0) (1 2)) ((0 1) (2)) ((0 1 2) ()))-                   (run* 4 vz (conj (== vz `(,vx ,vy))-                                    (appendo vx vy '(0 1 2)))))))))+                   (run* vx (conj (element-of vx '(1 2 3))+                                  (== vx 0))))+           (equal? '((() (s c h i s m))+                     ((s) (c h i s m))+                     ((s c) (h i s m))+                     ((s c h) (i s m))+                     ((s c h i) (s m))+                     ((s c h i s) (m))+                     ((s c h i s m) ()))

Nice test case! :smile:

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

+;; Copyright 2019 Google LLC+;;+;; Licensed under the Apache License, Version 2.0 (the License);+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;;     http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an AS IS BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++(library+    (trivial)+  (export do-test)+  (import (rnrs))++  ;;; Logic variables+  (define (var c)+    `(var . ,c))++  (define (var? x)+    (and (pair? x) (eq? 'var (car x))))++  (define (var=? x y)+    (eq? (cdr x) (cdr y)))++  ;;; Unification+  (define (lookup var s)+    (let ((b (and (var? var) (assp (lambda (u) (var=? u var)) s))))+      (if b (lookup (cdr b) s) var)))++  (define (lookup* var s)+    (let ((v (lookup var s)))+      (cond ((var? v) v)+            ((pair? v) (cons (lookup* (car v) s)+                             (lookup* (cdr v) s)))+            (else v))))++  (define (ext-s var value s)+    `((,var . ,value) . ,s))++  (define (unify u v s)+    (let ((u (lookup u s)) (v (lookup v s)))+      (cond ((eq? u v) s)+            ((var? u) (ext-s u v s))+            ((var? v) (ext-s v u s))+            ((and (pair? u) (pair? v))+             (let ((s (unify (car u) (car v) s)))+               (and s (unify (cdr u) (cdr v) s))))+            (else (equal? u v)))))++  ;;; Goals+  (define (succeed s.c) `(,s.c))+  (define (fail s.c) '())++  (define (== u v)+    (lambda (s.c)+      (let ((s (unify u v (car s.c))))+        (if s (succeed `(,s . ,(cdr s.c))) (fail s)))))++  (define (run n goal)+    (let ((result (goal '(() . 0))))+      (if (null? result)+          result+          (map car (take n result)))))++  (define (run* n var goal)+    (let ((result (goal '(() . 0))))+      (take n (map-$ (lambda (s.c) (lookup* var (car s.c))) result))))++  (define (choice var lst)+    (if (null? lst)+        fail+        (disj (== var (car lst))+              (choice var (cdr lst)))))++  (define (call/fresh f)+    (lambda (s.c)+      (let ((c (cdr s.c)))+        ((f (var c)) `(,(car s.c) . ,(+ c 1))))))++  (define (disj g1 g2)+    (lambda (s.c)+      (interleave (g1 s.c) (g2 s.c))))++  (define (conj g1 g2)+    (lambda (s.c)+      (bind (g1 s.c) g2)))++  (define (interleave $1 $2)

Thanks for the comments. This is much clearer now!

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

+;; Copyright 2019 Google LLC+;;+;; Licensed under the Apache License, Version 2.0 (the License);+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;;     http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an AS IS BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++(library+    (trivial)+  (export do-test)+  (import (rnrs))++  ;;; Logic variables+  (define (var c)+    `(var . ,c))++  (define (var? x)+    (and (pair? x) (eq? 'var (car x))))++  (define (var=? x y)+    (eq? (cdr x) (cdr y)))++  ;;; Unification+  (define (lookup var s)+    (let ((b (and (var? var) (assp (lambda (u) (var=? u var)) s))))+      (if b (lookup (cdr b) s) var)))++  (define (lookup* var s)+    (let ((v (lookup var s)))+      (cond ((var? v) v)+            ((pair? v) (cons (lookup* (car v) s)+                             (lookup* (cdr v) s)))+            (else v))))++  (define (ext-s var value s)+    `((,var . ,value) . ,s))++  (define (unify u v s)+    (let ((u (lookup u s)) (v (lookup v s)))+      (cond ((eq? u v) s)+            ((var? u) (ext-s u v s))+            ((var? v) (ext-s v u s))+            ((and (pair? u) (pair? v))+             (let ((s (unify (car u) (car v) s)))+               (and s (unify (cdr u) (cdr v) s))))+            (else (equal? u v)))))++  ;;; Goals+  (define (succeed s.c) `(,s.c))+  (define (fail s.c) '())++  (define (== u v)+    (lambda (s.c)+      (let ((s (unify u v (car s.c))))+        (if s (succeed `(,s . ,(cdr s.c))) (fail s)))))++  (define (run n goal)

Does run need a query var as well, like run*?

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

+;; Copyright 2019 Google LLC+;;+;; Licensed under the Apache License, Version 2.0 (the License);+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;;     http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an AS IS BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++(library+    (trivial)+  (export do-test)+  (import (rnrs))++  ;;; Logic variables+  (define (var c)+    `(var . ,c))++  (define (var? x)+    (and (pair? x) (eq? 'var (car x))))++  (define (var=? x y)+    (eq? (cdr x) (cdr y)))++  ;;; Unification+  (define (lookup var s)+    (let ((b (and (var? var) (assp (lambda (u) (var=? u var)) s))))+      (if b (lookup (cdr b) s) var)))++  (define (lookup* var s)+    (let ((v (lookup var s)))+      (cond ((var? v) v)+            ((pair? v) (cons (lookup* (car v) s)+                             (lookup* (cdr v) s)))+            (else v))))++  (define (ext-s var value s)+    `((,var . ,value) . ,s))++  (define (unify u v s)+    (let ((u (lookup u s)) (v (lookup v s)))+      (cond ((eq? u v) s)+            ((var? u) (ext-s u v s))+            ((var? v) (ext-s v u s))+            ((and (pair? u) (pair? v))+             (let ((s (unify (car u) (car v) s)))+               (and s (unify (cdr u) (cdr v) s))))+            (else (equal? u v)))))++  ;;; Goals+  (define (succeed s.c) `(,s.c))+  (define (fail s.c) '())++  (define (== u v)+    (lambda (s.c)+      (let ((s (unify u v (car s.c))))+        (if s (succeed `(,s . ,(cdr s.c))) (fail s)))))++  (define (run n goal)+    (let ((result (goal '(() . 0))))+      (if (null? result)+          result+          (map car (take n result)))))++  (define (run* n var goal)+    (let ((result (goal '(() . 0))))+      (take n (map-$ (lambda (s.c) (lookup* var (car s.c))) result))))++  (define (choice var lst)+    (if (null? lst)+        fail+        (disj (== var (car lst))+              (choice var (cdr lst)))))++  (define (call/fresh f)+    (lambda (s.c)+      (let ((c (cdr s.c)))+        ((f (var c)) `(,(car s.c) . ,(+ c 1))))))++  (define (disj g1 g2)+    (lambda (s.c)+      (interleave (g1 s.c) (g2 s.c))))++  (define (conj g1 g2)+    (lambda (s.c)+      (bind (g1 s.c) g2)))++  (define (interleave $1 $2)

I like that you've put meaningful names here like interleave as opposed to mplus. It would be helpful to add comments that explain how the names match up with the functions in the paper though.

jitwit

comment created time in 3 months

Pull request review commentgoogle/schism

experiment with u-kanren

+;; Copyright 2019 Google LLC+;;+;; Licensed under the Apache License, Version 2.0 (the License);+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;;     http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an AS IS BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++(library+    (trivial)+  (export do-test)+  (import (rnrs))++  ;;; Logic variables+  (define (var c)+    `(var . ,c))++  (define (var? x)+    (and (pair? x) (eq? 'var (car x))))++  (define (var=? x y)+    (eq? (cdr x) (cdr y)))++  ;;; Unification+  (define (lookup var s)+    (let ((b (and (var? var) (assp (lambda (u) (var=? u var)) s))))+      (if b (lookup (cdr b) s) var)))++  (define (lookup* var s)+    (let ((v (lookup var s)))+      (cond ((var? v) v)+            ((pair? v) (cons (lookup* (car v) s)+                             (lookup* (cdr v) s)))+            (else v))))++  (define (ext-s var value s)+    `((,var . ,value) . ,s))++  (define (unify u v s)+    (let ((u (lookup u s)) (v (lookup v s)))+      (cond ((eq? u v) s)

Should this clause be (and (var? u) (var? v) (var=? u v)? It seems like eq? might be too narrow.

jitwit

comment created time in 3 months

issue commentgoogle/schism

Remove `list-all-eq?`

Most of the functions that are available now are in https://github.com/google/schism/blob/master/scheme-lib/rnrs.ss and https://github.com/google/schism/blob/master/rt/rt.mjs#L102. We don't have eqv? support yet, but you're welcome to add it if that's helpful. I think eqv? will probably need to go in rt.mjs, but you can probably implement equal? in pure Scheme in rnrs.ss.

eholk

comment created time in 4 months

issue commentgoogle/schism

Remove `list-all-eq?`

Great! Do you have any questions? Do you have a rough idea how to get started?

eholk

comment created time in 4 months

issue commentgoogle/schism

Remove `list-all-eq?`

Hi @RikTheunis! No, this issue is not reserved; anyone who wants to is welcome to take it. I marked it as "good first issue" because I think it's doable without having to get too far into the guts of Schism. If you want to try it out, let me know and I can help guide you through it!

eholk

comment created time in 4 months

issue commentgoogle/schism

README.md review: What does Schism do?

Thanks for the suggestion. It looks like parts of the README are a little stale, since it was written at the very beginning of the project.

What about something like this?

Schism is an experimental compiler from Scheme to WebAssembly. It enables developers to run programs written in Scheme in the browser or server environments such as NodeJS. The compiler supports a subset of the R6RS version Scheme, and is self-hosting, meaning Schism is implemented in Schism itself.

AMDphreak

comment created time in 5 months

push eventgoogle/schism

Eric Holk

commit sha 6d46f65d6ff059fbb679d6935fe5537b4cc53ee7

Factor primitives into external libraries This splits the big list of primitive functions into their proper libraries. The majority of them go into `(rnrs)`. The pair mutator functions go into `(rnrs mutable-pairs)`. We had a handful of non-standard functions that go into `(schism)`, which is somewhat analogous to the `(chezscheme)` library that Schism used to pull a few functions from. Issue #19

view details

Eric Holk

commit sha 763a2d715684d707ddf6e13497ffe4b447170039

Update snapshot

view details

Eric Holk

commit sha f81874d78140feb03d8c3454ebc7e81fd72f49d3

Remove deprecated schism.ss

view details

Eric Holk

commit sha f1ef9e11f2ea1bac84a290da7102e01b3070c596

Copy rnrs librarys to scheme-lib/ This should have been a move, but unfortunately, because the paths are hardcoded, we need to make a compiler snapshot with the new location.

view details

Eric Holk

commit sha fbc09322c8a63fbe9d426624fb7c62678c3b9a6a

Updating snapshot

view details

Eric Holk

commit sha 1486de62395170c670d1670de11b4b19b6fb21ae

Remove stale libraries

view details

Eric Holk

commit sha 85d2b4c47bb90d56dc4a40612de0b3505b80b91f

Tweaks to enable Guile bootstrap

view details

Eric Holk

commit sha 9c6946ae27d026253bbf2274a9b8f9ad785e6bb5

Updating snapshot

view details

Eric Holk

commit sha c86cc0e41a19c093ac9b0a689ba717cf4fa32e55

Fix bootstrap-from-guile.scm

view details

Eric Holk

commit sha 76f6091cae5e830f5413fe7261501fc89ad8dad5

Steps towards fixing Playground

view details

Eric Holk

commit sha 7981382ae85deaca1c1400029bc7d8ac558c6d25

Merge pull request #90 from eholk/hardcoded-libraries Factor primitives into external libraries

view details

push time in 5 months

PR merged google/schism

Factor primitives into external libraries

This splits the big list of primitive functions into their proper libraries. The majority of them go into (rnrs). The pair mutator functions go into (rnrs mutable-pairs). We had a handful of non-standard functions that go into (schism), which is somewhat analogous to the (chezscheme) library that Schism used to pull a few functions from.

Issue #19

+494 -443

8 comments

16 changed files

eholk

pr closed time in 5 months

pull request commentgoogle/schism

Factor primitives into external libraries

The playground works in Chrome now if you give Chrome the argument --js-flags="--experimental-wasm-anyref experimental-wasasm-return_call".

I think this PR is at a point where I'd feel comfortable merging it. @wingo - what do you think?

eholk

comment created time in 5 months

push eventeholk/schism

Eric Holk

commit sha bcd53f7bbcb945f854e4271ed4ca7014fd5d2c05

Fix module loading in Playground

view details

push time in 5 months

more