logoalt Hacker News

miki123211today at 6:43 AM0 repliesview on HN

See also: https://juxt.github.io/allium/ (not affiliated in any way, just an interesting project)

I'm using something similar-ish that I build for myself (much smaller, less interesting, not yet published and with prettier syntax). Something like:

    a->b # b must always be true if a is true
    a<->b # works both ways
    a=>b # when a happens, b must happen
    a->fail, a=> fail # a can never be true / can never happen
    a # a is always true


So you can write:

    Product.alcoholic? Product in Order.lineItems -> Order.customer.can_buy_alcohol?
    u1 = User(), u2=User(), u1 in u2.friends -> u2 in u1.friends
    new Source() => new Subscription(user=Source.owner, source=Source)
    Source.subscriptions.count>0 # delete otherwise
This is a much more compact way to write desired system properties than writing them out in English (or Allium), but helps you reason better about what you actually want.