Conversation

I only wanted to learn how (dependent) type systems work, but ended up prototyping my own programming language inspired by and . It currently only supports basic expressions and type inference, but may become more useful in the future
Quote Tweet
Hello, world! Star and watch our repository on GitHub for imminent updates github.com/kara-lang/Kara
1
14
Why dependent types? If all works well, I want to prevent out of bounds access in arrays at compile-time. That is, this will not type check in (a future version of) : let a1 = [1,2,3] a1[3] // type error, out of bounds let a2 = [4,5,6] (a1 + a2)[6] // type error, OOB
3
1
It'd come down to the types you give your indexing and concatenation functions. Eg: _[_] : {n} {A} -> Array n A -> Fin n -> A _+_ : {n m} {A} -> Array n A -> Array m A -> Array (n + m) A
1
1
At the point where you want to check `(a1 + a2)[6]`, the addition in the `_+_` reduces definitionally, so `a1 + a2` is of type `Array 6 Int`. And then you'd get a type error saying that you can't make a `Fin 6` using the numeric literal `6`.
1
2
Thanks, been watching that repository already. I'm still at a stage of implementing dependent pattern matching, and distracted by the dev tools situation. As I start playing w/ more code, I need syntax highlighting and language server with proper error messages for my language πŸ™ˆ
1
1
Replying to and
Thanks! Code I posted here in the thread will not at work at all right now, example snippets are aspirational πŸ˜…. The only way to sanely interact with it is through test cases. Generic types are not supported yet, and it does only simple evaluation in type signatures. V early WIP
1