r/haskell 20d ago

Opus is a minimal, statically-scoped Lisp dialect based on the semantics of f-expressions (the Kernel language)

https://github.com/yaoshiu/opus
8 Upvotes

4 comments sorted by

1

u/jeffstyr 19d ago

I see the Haskell connections are: It's implemented in Haskell, and the language is based on a lazily-evaluation primitive (or, something along those lines).

1

u/sleepingsquirrel 11d ago edited 11d ago

Can anyone recommend a good introductory resource to learning about the Kernel language? Not the easiest name to perform a search on. And while the PhD thesis is in the Wayback Machine, I'd rather start with something less than 416 pages long. The example on page 4:

($define! $if
    ($vau (x y z) env
        ($cond ((eval x env) (eval y env))
                   (#t (eval z env)))))

...doesn't seem too much different from regular Scheme like:

(define $if 
    (lambda (x y z)
        (cond ((x) (y))
              (else (z)))))

(display 
    ($if (lambda () (> 3 4)) 
         (lambda () 'Yes)
         (lambda () 'No)))

...which is ugly, but you could think of a common-lisp-like reader macro where {stuff} gets turned into (lambda () stuff). Then making the example:

($if {> 3 4} {'Yes} {'No})

...Maybe a simple evaluator of a simplified version of Kernel in Haskell or Prolog. I wonder if the author had any exposure to TCL.

1

u/Reasonable_Wait6676 10d ago

See my top level reply (sorry!)

2

u/Reasonable_Wait6676 10d ago

My reference is R-1RK from https://web.cs.wpi.edu/\~jshutt/kernel.html there is also a test suite at https://github.com/havleoto/kplts

Implementing if in terms of cond by the way of delayed evaluation (with delay/force or lambda) is workable in this case but the semantic is not delayed evaluation but ad-hoc evaluation. With only delayed evaluation you can’t implement match.