Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Meta Lambda Calculus (MLC) #2

Open
kamil-adam opened this issue Aug 11, 2022 · 1 comment
Open

Implement Meta Lambda Calculus (MLC) #2

kamil-adam opened this issue Aug 11, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kamil-adam
Copy link
Contributor

kamil-adam commented Aug 11, 2022

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?


  • @ - define and special word
  • # - comment
  • : - block
  • ; - many instruction in one line

About expression

  • abs (\ symbol) is abstraction.
  • if (? symbol).
  • guard (| symbol) is or line. It is sugar for if.
    • guard K (|K symbol, guard constants). It Is hack.
    • guard is (|= symbol, guard equals, case).
    • guard in (guard belongs to, case list).
  • let (& symbol) is and line. It is sugar for abs. Real sugar. Maybe we need macros?

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

  • Can we break lines?
  • How we should break lines?
  • Special character on end line or brackets?
  • Braces?
  • Indentation?
  • Tabs?

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 kamil-adam added the enhancement New feature or request label Aug 11, 2022
@kamil-adam kamil-adam pinned this issue Aug 11, 2022
@kamil-adam kamil-adam changed the title Implement MLC Implement Meta Lambda Calculus (MLC) Aug 11, 2022
@kamil-adam kamil-adam transferred this issue from helvm/helpa Sep 14, 2022
@kamil-adam kamil-adam pinned this issue Sep 14, 2022
@kamil-adam kamil-adam added this to the 1. Lambda Calculus milestone Sep 27, 2022
@kamil-adam
Copy link
Contributor Author

  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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants