-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fruit Language
Basic Syntax uses only two special chars \
and `
\param body
`fun arg
Sugar Syntax uses (){}[]"'+=
.
;
, ,
, .
and :
are not syntax but functions.
(f x y z)
Desugared
```f x y z
{
;(a b) \val1
;(a b c) \val2
val1 val2
}
Desugared
(
;(a b) \val1
;(a b c) \val2
val1 val2
)
-
;
isT
combinator
List with nil in end. But maybe better name is Stack
.
Lists are lazy because in Pure Functional Fruit everything is lazy.
[, a , b , c ]
Desugared
(, a , b , c .)
-
,
isV
combinator viapair
/cons
. -
.
isnil
.
Strings are lazy because string is NilList of chars.
"Hello"
Desucared:
[, 'H , 'e , 'l , 'l , 'o]
It is only literal. In code it is the same like Natural.
'a
- Natural -> generated, for numbers we need defined
.
(nil
) and:
(succ
), so:- 0 is
.
- 1 is
: .
- 2 is
: (: .)
- 0 is
- Integer -> pair sign natural, sign is bool, plus is
false
, minus istrue
, so:- +0 is
, false .
- -0 is
, true .
- +1 is
, false (: .)
- -1 is
, true (: .)
- +0 is
Extra Syntax uses two chars #
and @
.
# this is comment
Work in progress.
Because Fruit can by compiled to Combinators, we can write alternative implementation in Combinators
Compiled to Combinators
@K
Input is String and Output is String. So all program is function which consume String and produce String
For libraries we need one hack. Library (a separate file with functions) must end with the function _
.
;(a b) \val1
;(a b c) \val2
_
We use also one special char ~
~ true (\x \y x)
~ false (\x \y y)