helvm / heltc

🎓 🏫 HelTC - Haskellish Esoteric Lambda True Calculator to Esoteric Languages implemented in Haskell
http://helvm.org/heltc
MIT License
6 stars 0 forks source link

Implement Meta Lambda Calculus (MLC) #2

Open kamil-adam opened 2 years ago

kamil-adam commented 2 years ago

apply

# apply combinator create one local variable/function/definition
#\x \f f x @ &
@ apply \x \f f x
@ ! apply
@ & apply
@ |> apply
& (lambda) ( \ function 
  do something
)
! (lambda1) \ function1 \ 
! (lambda2) \ function2 \ 

Lambdas and Let

someLambda1 (\ param1 someLambda2 (\ param2 someLambda3 (\ param3 param1 param2 param3)))
someLambda1 (\ param1 
  someLambda2 (\ param2 
    someLambda3 (\ param3 
      param1 param2 param3
    )
  )
)
someLambda1 \ param1 \
someLambda2 \ param2 \
someLambda3 \ param3 \
param1 param2 param3 

so maybe:

someLambda1 @ name1
\ param1 body1 @ name1

or:

someLambda1 : name1
\ param1 body1 : name1

Maybe it is too crazy?


About expression

Example expressions

: function ! param1 ! param2 result

: variable ? condition expression1 expression2

; guard is predicate
| guard1 result1
| guard2 result2
default result
expression

; It is sugar for:
? (guard1 expression) result1
? (guard2 expression) result2
result

; it is possible do define `|` as function
: | ! guard ! body ! tail ! expression ? (guard expression) body (tail expression)
: default ! body ! expression body; It is true

& id1 init1
& id2 init2
expression

; It is sugar for:
! variable1 ! variable2 expression init1 init2

Issue with breaking line

Example break lines

: function \
  \ param1 
  \ param2 
  result

: variable \
  ? condition 
  result1
  result2

: variable \
  | guard1 result1
  | guard2 result2 
  default result
  expression

: variable \
  ? (guard1 expression) result1
  ? (guard2 expression) result2
  result

: variable \
  & id1 init1
  & id2 init2
  result

: variable \
  \ id1
  \ id2
  result
  init1
  init2
a b c; => (a b) c ; => default order
a ` b c; => a (b c) => reverted order
! s v o; => v s o; => object order
o s v; => pipe order
o s v; => stack order
kamil-adam commented 1 year ago
  1. Split source by NewLine
  2. Parse every line separately
  3. If we have error we append next line to actual parsed lines, and we will parse again