ethereum / moon-lang

Minimal code-interchange format
MIT License
193 stars 20 forks source link

documentation: preview #26

Open Kesanov opened 7 years ago

Kesanov commented 7 years ago

This is not really finished. I just want to show, how does the documentation currently look like.

There might be some mistakes in the type signatures (I am not sure about match in particular).

I do not mind changing the format of documentation if it makes sense.

VictorTaelin commented 7 years ago

OK, this is really cool! Just give me some time to test it (tomorrow?)

Kesanov commented 7 years ago

Of course, I am glad you like it. I did not really try to run this (compiler does not understand : -> == right now anyway), so it is meant as a preview, how could documentation possibly look like.

Kesanov commented 7 years ago

Do you think I should write forall a -> forall b -> (a -> b) -> a -> b instead of (a -> b) -> b?

Kesanov commented 7 years ago

Oh and is it possible to use equality on functions in moon? Otherwise one 1 == val 1 end does not make sense.

Kesanov commented 7 years ago

Otherwise I will have to implement equal and use that instead...

Kesanov commented 7 years ago

An alternative approach - so far my favourite:

val = ...
end = ...

decription =
  "returns 1 if any element satisfies condition"

complexity =
  "O(N) where N is length of list"

this =
  cond : a -> Int =>
  list : (a -> b) -> b =>

    list
      x => xs => i =>
        (if (cond x)
          1
          (xs (add i 1)))
      i => 0
      0

examples =
  [ this (eql 3) (val 2 end) == 0
  , this (eql 3) (val 3 end) == 1
  ]

this

BTW is it a problem, that tooling (like moon-tool, repl and language server) will be able to extract terms from lets which are not normally visible?