3 ms·
Coalton [1] is a Lisp language that has Hindley-Milner type inference with type classes. Its syntax actually resembles the prototype syntax from TFA pretty clos
by reikonomusha 2y ago
Coalton [1] is a Lisp language that has Hindley-Milner type inference with type classes. Its syntax actually resembles the prototype syntax from TFA pretty closely. The Coalton syntax-equivalent would be:
(define-type (Option :a)
(Some :a)
None)
(let ((x (Some 5)))
(match x
((Some y) y)
((None) (random))))
(declare random (Distribution :a => Unit -> :a))
(define (random)
(sample (thread-rng)))
(define-class (Eq :t)
(= (:t -> :t -> Boolean)))
(define-instance (Eq Number)
(define (= lhs rhs)
(num-equal lhs rhs)))
Of course types and classes like Option and Eq are built-in already.
Coalton is based on Common Lisp (and allows free mixing with CL code) instead of Scheme however, though Coalton is a Lisp-1 and would feel relatively at-home to any Scheme programmer.
[1] https://github.com/coalton-lang/coalton https://github.com/coalton-lang/coalton
- maplant 2y agoVery cool! I saw a number of projects pretty similar to this one, typed racket for example. I didn’t really talk about it too much but what I want to do is flip the direction. Coalton is based on CL, but what I would like is scheme to essentially be a set of Gouki function with the signature top … -> top. Then, i want to see how fast I can make the interaction between them be using different analysis like k-CFA
- anonzzzies 2y agoCoalton is great. Indeed often it's much easier to just implement on top of either SBCL or ChezScheme; they are very fast and chances are you are not going to make anything as or more performant, better documented etc. However, reimplementation in Rust is not too bad as that's were we need to be for small, fast, low level runtimes. If the goal was 'just' their own language, I feel just a an implementation on top of CL/SBCL + Coalton would've been faster to build, easier to maintain and probably far more performant. Less fun though!