Finally, my #Funktal compiler can emit correct #Uxntal for some simple examples.
The first one shows named functions, lambda functions and primitive types:
functions {
sq = (\Int <- x:Int. x x *)
}
main {
6 7 (\ Int <- x:Int <- y:Int . x y * sq )
print
}
Funktal uses postfix notation for expressions and types. In Haskell, the sq function would be
sq :: Int -> Int
sq = \x -> x*x
The second example shows the use of an algebraic data type, a tuple:
types {
Tup = Int Int MkTup
}
main {
6 7 MkTup (\ Int <- (x y MkTup): Tup . x y * )
print
}
MkTup creates a tuple of two integers. In Haskell this would be
data Tup = MkTup Int Int
The lambda function pattern matches on the type, so x and y bind to the stored values.
#Funktal
The second example shows the use of an algebraic data type, a tuple:
types {
Tup = Int Int MkTup
}
main {
6 7 MkTup (\ Int <- (x y MkTup): Tup . x y * )
print
}
MkTup creates a tuple of two integers. In Haskell this would be
data Tup = MkTup Int Int
The lambda function pattern matches on the type, so x and y bind to the stored values.