• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

Revision1edc88bf86dd526d4d1b39bd88a228f8b09e40fa (tree)
Time2023-10-21 13:52:25
AuthorCorbin <cds@corb...>
CommiterCorbin

Log Message

Try prototyping type inference for algebras.

I'm really *really* thinking about how to avoid having to write out the
types of the carriers, but I'm not quite seeing how to do it. I'm also
trying to avoid writing out the names of elements of signatures, but I
might have to give up.

Change Summary

Incremental Difference

--- a/movelist/cammy-repl.scm
+++ b/movelist/cammy-repl.scm
@@ -474,6 +474,21 @@
474474 (cons (cons name (vector most-recent-template "")) templates))))
475475 (begin (display "Need a name, sorry.") (newline))))
476476
477+(define (cammy-alg° alg sigs ctx)
478+ (conde
479+ ((nullo alg) (nullo sigs))
480+ ((fresh (expr d sig p s t)
481+ (conso expr d alg) (conso sig p sigs) (conso s t sig)
482+ (cammy-holes° expr s t ctx)
483+ (cammy-alg° d p ctx)))))
484+
485+(define (cammy-display-alg exprs)
486+ (display "Algebra: ")
487+ (display (car (run 1 (q) (fresh (sig ctx) (conso sig ctx q)
488+ (cammy-alg° (map build-holes exprs) sig ctx)))))
489+ (newline))
490+
491+
477492 (define help "Basic usage: Enter a Cammy expression to preview its elements.
478493
479494 When an expression is valid, it will be saved to '_'.
@@ -554,6 +569,7 @@ To write the hive, give a filename explicitly:
554569 ['save
555570 (with-output-to-file (read) (lambda () (write-json hive)))
556571 (display "Wrote hive to file.") (newline)]
572+ [('alg . exprs) (cammy-display-alg (map lookup exprs))]
557573 ; eof
558574 [(? eof-object?) (newline) (display "Peace!") (newline) (exit 0)]
559575 ; eval