←back to thread

83 points boris_m | 1 comments | | HN request time: 0.21s | source
1. frisia ◴[] No.42075465[source]
This is very cool! I'm actually working on something very similiar, as I wanted a scripting language with very robust pattern matching and macro-like capabilities with term rewriting for writing DSLs. Seeing this project is very inspiring, nad it seems we have very similiar ideas, my original idea was also that undefined terms would just be the way to construct data types. However, I want the lazyness to be optional in my language, and for completely undefined terms to throw errors as I think the ergonomics of just treating undefined terms as valid data would be a bad programming experience. In my (upcoming language, hopefully), data would be constructed like this:

  pair a b = '(pair a b)
where ' is shorthand for quoting, like in lisp. If you want to explicitly define datatypes on demand, you can just manually quote and not use the pair function constructor. One thing I thought about to was smart constructors, like say if you want to define the mod 3 group:

  zero = 'zero
  s (s (s x))) = x
  s x = '(s x)

if values are always constructed with either "s" or "zero", the smart constructor of s enforces you can't create any terms with an s-chain of 3 or higher, IF the function arguments are eagerly evaluated.