All Projects → uwu-tech → Kind

uwu-tech / Kind

Licence: mit
A modern proof language

Programming Languages

javascript
184084 projects - #8 most used programming language
scheme
763 projects
haskell
3896 projects
Nix
1067 projects
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Kind

Write You A Haskell
Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)
Stars: ✭ 3,064 (+47.66%)
Mutual labels:  type-theory, lambda-calculus, functional-programming
Church
⛪️ Church Encoding in JS
Stars: ✭ 107 (-94.84%)
Mutual labels:  lambda-calculus, functional-programming
lplzoo
Fine-grain implementations of common lambda calculi in Haskell, tested with QuickCheck
Stars: ✭ 32 (-98.46%)
Mutual labels:  lambda-calculus, type-theory
Combinators Js
🐦 Some combinators
Stars: ✭ 114 (-94.51%)
Mutual labels:  lambda-calculus, functional-programming
cicada
Cicada Language
Stars: ✭ 9 (-99.57%)
Mutual labels:  type-theory, theorem-prover
Type-Theory
Lecture note on Lambda Calculus and Types for FLOLAC
Stars: ✭ 26 (-98.75%)
Mutual labels:  lambda-calculus, type-theory
Lambda
🔮 Estudos obscuros de programação funcional
Stars: ✭ 297 (-85.69%)
Mutual labels:  lambda-calculus, functional-programming
Plt
λΠ Programming Language Theory
Stars: ✭ 4,609 (+122.12%)
Mutual labels:  type-theory, functional-programming
Plam
An interpreter for learning and exploring pure λ-calculus
Stars: ✭ 385 (-81.45%)
Mutual labels:  lambda-calculus, functional-programming
Magic In Ten Mins
十分钟魔法练习
Stars: ✭ 327 (-84.24%)
Mutual labels:  lambda-calculus, functional-programming
gidti
Book: Gentle Introduction to Dependent Types with Idris
Stars: ✭ 70 (-96.63%)
Mutual labels:  lambda-calculus, type-theory
Lambda
Fun with λ calculus!
Stars: ✭ 65 (-96.87%)
Mutual labels:  lambda-calculus, functional-programming
Curryhoward
Automatic code generation for Scala functions and expressions via the Curry-Howard isomorphism
Stars: ✭ 229 (-88.96%)
Mutual labels:  lambda-calculus, functional-programming
types-and-programming-languages
Exercises from Benjamin Pierce's "Types and Programming Languages" textbook + extras!
Stars: ✭ 92 (-95.57%)
Mutual labels:  lambda-calculus, type-theory
Lambda Talk
A Flock of Functions: Combinators, Lambda Calculus, & Church Encodings in JS
Stars: ✭ 315 (-84.82%)
Mutual labels:  lambda-calculus, functional-programming
Fp Core.rs
A library for functional programming in Rust
Stars: ✭ 772 (-62.8%)
Mutual labels:  lambda-calculus, functional-programming
Y Combinator For Non Programmers
🍱 Y Combinator for Non-programmers: A Wild Introduction to Computer Science
Stars: ✭ 109 (-94.75%)
Mutual labels:  lambda-calculus, functional-programming
Python Memoization
A powerful caching library for Python, with TTL support and multiple algorithm options.
Stars: ✭ 109 (-94.75%)
Mutual labels:  functional-programming
Freasy Monad
Easy way to create Free Monad using Scala macros with first-class Intellij support.
Stars: ✭ 112 (-94.6%)
Mutual labels:  functional-programming
Fsconfig
FsConfig is a F# library for reading configuration data from environment variables and AppSettings with type safety.
Stars: ✭ 108 (-94.8%)
Mutual labels:  functional-programming

Kind

A minimal, efficient and practical programming language that aims to rethink functional programming from the scratch, and make it right. Under the hoods, it is basically Haskell, except without historical mistakes, and with a modern, consistent design. On the surface, it aims to be more practical, and to look more like conventional languages. Kind is statically typed, and its types are so powerful that you can prove mathematical theorems on it. Compared to proof assistants, Kind has:

  1. The smallest core. Check FormCore.js or Core.kind. Both are < 1000-LOC complete implementations!

  2. Novel type-level features. Check this article on super-inductive datatypes.

  3. An accessible syntax that makes it less scary. Check SYNTAX.md.

  4. A complete bootstrap: the language is implemented in itself. Check it here.

  5. Efficient real-world compilers. Check http://uwu.tech/ for a list of apps. (WIP)

Usage

npm telegram

  1. Choose a release. We'll use JavaScript here but ChezScheme is also available.

  2. Install Kind using npm:

npm i -g kind-lang
  1. Save the file below as Main.kind:
Main: IO(Unit)
  IO {
    IO.print("Hello, world!")
  }
  1. Type-check it:
kind Main
  1. Run it:
kind Main --run
  1. Have fun!

Things you can do with Kind:

Compile programs and modules to several targets.

Kind has an universal compiler that targets several back-ends. Just find what you need on Kind, and compile it with kind Main --lang. For example, to generate a QuickSort function in JavaScript, just type kind List.quicksort --js. You may never write code in any other language! Available targets: --js, --scm. Several more will be available eventually.

Create live applications.

Kind has an interconnected back-end that allows you to create rich, interactive applications without ever touching databases, TCP packets or messing with apis. Just add a file to base/App and it will be available on http://uwu.tech/. You can fork entire applications - not just the front-end, but all of it, back-end, database, and networking - in seconds.

Prove theorems.

No, theorems are not scary things mathematicians do. For programmers, they're more like unit tests, except they can involve symbols, allowing you to cover infinitely many test cases. If you like unit tests, you'll love theorems. To learn more, check THEOREMS.md. You can also compile Kind programs and proofs to a minuscle core language with the --fmc flag (example: kind Nat.add.assoc --fmc). Try it!

Deploy Smart-Contracts.

(Soon.)

Examples

Some programs

// A 'Hello, world!"
Main: IO(Unit)
  IO {
    IO.print("Hello, world!")
  }
// Quicksort (using recursion)
quicksort(list: List<Nat>): List<Nat>
  case list {
    nil:
      []
    cons:
      fst = list.head
      min = filter!((x) x <? list.head, list.tail)
      max = filter!((x) x >=? list.head, list.tail)
      quicksort(min) ++ [fst] ++ quicksort(max)
  }
// List iteration (using folds)
some_text: String
  List.foldl!!("",
    (str, result) 
      str = String.to_upper(str)
      str = String.reverse(str)
      result | str,
    ["cba","fed","ihg"])
// List iteration (using fors)
some_text: String
  result = ""
  for str in ["cba","fed","ihg"] with result:
    str = String.to_upper(str)
    str = String.reverse(str)
    result | str
  result
// Map, Maybe, String and Nat sugars
sugars: Nat
  key  = "toe"
  map  = {"tic": 1, "tac": 2, key: 3} // Map.from_list!([{"tic",1}, ...])
  map  = map{"tic"} <- 100            // Map.set!("tic", 100, map)
  map  = map{"tac"} <- 200            // Map.set!("tac", 200, map)
  map  = map{ key } <- 300            // Map.set!(key, 300, map)
  val0 = map{"tic"} <> 0              // Maybe.default!(Map.get!("tic",map), 0)
  val1 = map{"tac"} <> 0              // Maybe.default!(Map.get!("tac",map), 0)
  val2 = map{ key } <> 0              // Maybe.default!(Map.get!(key, map), 0)
  val0 + val1 + val2                  // Nat.add(val0, Nat.add(val1, val2))
// List monadic block: returns [{1,4},{1,5},{1,6},{2,4},...,{3,6}]
my_list: List<Pair<Nat,Nat>>
  List {
    get x = [1, 2, 3]
    get y = [4, 5, 6]
    return {x, y}
  }

Check many List algorithms on base/List!

Some types

// A boolean
type Bool {
  true
  false
}
// A natural number
type Nat {
  zero
  succ(pred: Nat)
}
// A polymorphic list
type List <A: Type> {
  nil
  cons(head: A, tail: List<A>)
}
// A polymorphic pair
type Pair <A: Type, B: Type> {
  new(fst: A, snd: B)
}
// A polymorphic dependent pair
type Sigma <A: Type, B: A -> Type> {
  new(fst: A, snd: B(fst))
}
// A polymorphic list with a statically known size
type Vector <A: Type> ~ (size: Nat) {
  nil                                              ~ (size = 0) 
  cons(size: Nat, head: Nat, tail: Vector<A,size>) ~ (size = 1 + size)
}
// A bounded natural number
type Fin ~ <lim: Nat> {
  zero<N: Nat>               ~ (lim = Nat.succ(N))
  succ<N: Nat>(pred: Fin<N>) ~ (lim = Nat.succ(N))
}
// The type used in equality proofs
type Equal <A: Type, a: A> ~ (b: A) {
  refl ~ (b = a)
}
// A burrito
type Monad <M: Type -> Type> {
  new(
    bind: <A: Type, B: Type> M<A> -> (A -> M<B>) -> M<B>
    pure: <A: Type> A -> M<A>
  )
}
// Some game entity
type Entity {
  player(
    name: String
    pos: V3
    health: Nat
    items: List<Item>
    sprite: Image
  )
  wall(
    hitbox: Pair<V3, V3>
    collision: Entity -> Entity
    sprite: Image
  )
}

Check all core types on base!

Some proofs

// Proof that `a == a + 0`
Nat.add.zero(a: Nat): a == Nat.add(a, 0)
  case a {
    zero: refl
    succ: apply(Nat.succ, Nat.add.zero(a.pred))
  }!
// Proof that `1 + (a + b) == a + (1 + b)`
Nat.add.succ(a: Nat, b: Nat): Nat.succ(a + b) == (a + Nat.succ(b))
  case a {
    zero: refl
    succ: apply(Nat.succ, Nat.add.succ(a.pred, b))
  }!
// Proof that addition is commutative
Nat.add.comm(a: Nat, b: Nat): (a + b) == (b + a)
  case a {
    zero:
      Nat.add.zero(b)
    succ: 
      p0 = Nat.add.succ(b, a.pred)
      p1 = Nat.add.comm(b, a.pred)
      p0 :: rewrite X in Nat.succ(X) == _ with p1
  }!

Check some Nat proofs on base/Nat/add!

A web app

// Render function
App.Hello.draw: App.Draw<App.Hello.State>
  (state)
  <div style={"border": "1px solid black"}>
    <div style={"font-weight": "bold"}>"Hello, world!"</div>
    <div>"Clicks: " | Nat.show(state@local)</div>
    <div>"Visits: " | Nat.show(state@global)</div>
  </div>

// Event handler
App.Hello.when: App.When<App.Hello.State>
  (event, state)
  case event {
    init: IO {
      App.watch!(App.room_zero)
      App.new_post!(App.room_zero, App.empty_post)
    }
    mouse_down: IO {
      App.set_local!(state@local + 1)
    }
  } default App.pass!

Source: base/App/Hello.kind

Live: http://uwu.tech/App.Hello

In order to run this or any other app you should follow this steps:

  • The app should be in base/App folder
  • Install necessary packages in web folder with npm i --prefix web/
  • Install js-beautify using sudo npm i -g js-beautify
  • Run our local server with node web/server
  • Build the app you want with node web/build App.[name of app] (in this example would be node web/build App.Hello)
  • Open localhost in your favorite browser and see your app working

Future work

There are so many things we want to do and improve. Would like to contribute? Check CONTRIBUTE.md. Also reach us on Telegram. We're friendly!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].