‹ BackHN Continuity

Thread

Bend – a language that blocks AI mistakes via proof and runs on GPUs

616 points · 327 comments · nicolas-siplis

  1. amluto · · focus · HN ↗
    Maybe in our brave new world only the "laws" will matter and the implementation language is irrelevant to humans. In the mean time I have some questions about the "guide", which claims to define the entire language:

    <a href="https:&#x2F;&#x2F;github.com&#x2F;bendlang&#x2F;bend&#x2F;blob&#x2F;main&#x2F;guide&#x2F;GUIDE.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bendlang&#x2F;bend&#x2F;blob&#x2F;main&#x2F;guide&#x2F;GUIDE.md

    Let&#x27;s see:

    - There are no infinite loops, and recursion is kind of softly bounded to 2^48-1. This sounds grrrreat for games. I guess they have to stop working after a while? (What would be wrong with addressing this conceptually like Lean does? Have a way to annotate a term as possibly non-terminating?)

    - We seem to have Data and Type and Kind, and they don&#x27;t mean what they conventionally do. &#x27;-&#x27; means &quot;used 0 types&quot;. And the example is:

        def length(a, -A: Kind(a), xs: List&lt;a, A&gt;) -&gt; Nat:
          match xs:
            case Nil{}:
              0n
            case Con{h, t}:
              1n+length(a, A, t)
    
    But wait! A is used albeit not at runtime. Is it possible that this actually intends &quot;A may be used any number of times and is itself the name of a - type&quot;? Shouldn&#x27;t that be spelled &quot;A: Kind(a) &amp; -&quot; or similar? Why does the kind even matter for this example?

    - I don&#x27;t understand the Array example:

        import Base
        
        def main() -&gt; Array&lt;U32&gt; &amp; U32:
          a = [0 : U32*8n] # new array with 8 copies of 0
          a[5] &lt;- 42       # performs an in-place rewrite
          a[5]             # reads index 5
    
    What is the return type of this function? It looks like it returns U32. So what&#x27;s &quot;Array&lt;U32&gt; &amp; U32&quot;?

    - I don&#x27;t even understand the Array explanation:

    &gt; The slot count after * is a power of two; [0 : U32^3n] names the depth instead.

    Okay, the 8 in *8n above is indeed a power of two. Does the language require it? Does it actually mean 2^8? What is the &quot;depth&quot; of an array? Does this language not have non-power-of-two-sized arrays?

    At this point I stopped reading.

    1. LightMachine · · focus · HN ↗
      Nothing wrong with addressing it conceptually! We will, in the upcoming versions, probably via codata &#x2F; coroutines. For V1, I&#x27;m keeping the language set smell. When it is stable, we&#x27;ll add more features. Lean had 10+ years to mature; Bend is on day 1.

      `-` means &quot;erased argument&quot;. You can use an erased argument as many times as you want, in erased positions. That&#x27;s also how QTT works (Idris2 is based on it). This example is there precisely to introduce Kinds, which are universes indexed on quantities.

      - Kind(&amp;2) is inhabited by clonable values. - Kind(&amp;1) is inhabited by linear values. - Kind(&amp;0) is like Rocq&#x27;s Prop.

      `A &amp; B` is just sugar for the pair type former (which is sugar for a sigma).

      Thanks for your questions and patience!

      1. amluto · · focus · HN ↗
        So why does the length function take the ‘a’ parameter (the type of the elements?) and its Kind? Wouldn’t the type imply the kind? Why does the kind matter? Is the - a constraint on the kind? How would the program be different without the -?

        When you say “pair type former” do you mean that Array&lt;U32&gt; &amp; U32 is what Rust would call (Array&lt;U32&gt;, U32)? If so, why does that example function actually return a value of this type? It sure looks like it returns plain U32.

        &gt; You can use an erased argument as many times as you want, in erased positions.

        What’s the rationale for this? Why is an “erased” position special? What is an erased position, anyway?

        ISTM if I want to use an affine term that has zero size at runtime as a token that may be used at most once, I think I wouldn’t want an exception for using it in an “erased” position. Can I have a function like a -&gt; a &amp; a where the input is “erased”?

        1. [deleted] · · focus · HN ↗

          [deleted]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.