项目作者: kenpusney

项目描述 :
The Federal of Programming Languages
高级语言:
项目地址: git://github.com/kenpusney/fed.git
创建时间: 2016-04-11T06:11:23Z
项目社区:https://github.com/kenpusney/fed

开源协议:

下载


Fed Programming Language

  • Derived from Ng
  • Explicit type, although sometimes it can be inferred
  • No macros, they are all bullshit (instead you can invent one)
  • Templates made simple
  • ADT && HKT support
  • Unified function call syntax
  • Value semantics
  • Strong type safety
  • No GC and lifetime annotation

Examples

  1. -- cons means: Constructor
  2. type List<'t> = cons Cons('t, List<'t>) | cons Nil
  3. -- this is it
  4. type array<'t, arity: Int>
  5. get :: array<'t, n> -> Int -> Maybe 't
  6. -- You can also emit the `array<Int, 5>` shit by some compiler magic
  7. val shit: array<Int, 5> {1, 2, 3, 4, 5}
  8. -- It's 4, seriously
  9. shit.get(3) |> print
  10. val list: Cons(1, Cons(2, Cons(3, Cons(4, Cons(5)))))
  11. length :: List<'t> -> Int
  12. length l = case l
  13. | Cons(x, xs) => length(xs) + 1
  14. | Nil => 0
  15. type Fact<x: Int> = {
  16. value: x * Fact<x-1>.value
  17. }
  18. -- Fuck me, please
  19. type Fact<0> = {value: 1}
  20. fact :: Int -> Int
  21. fact n = Fact<n>::value
  22. -- array_of_int<5> == array<Int, 5>
  23. type array_of_int = array<Int>
  24. -- array_of_char<5> != array<Char, 5>
  25. type! array_of_char = array<Char>
  26. type ref<'t> = ref 't
  27. (~>) :: ref<'t> -> 't
  28. val shit2 = ref shit
  29. -- :) shit2~>get(3) for short
  30. shit2.~>.get(3)