Closed julianhyde closed 12 months ago
suchthat
should be lower case, not camel case (suchThat
) as originally proposed. Other languages have keywords composed of multiple words: ML (andalso
, infixl
, infixr
, orelse
), Haskell (forall
, newtype
) Java (goto
, instanceof
, strictfp
), Kotlin (typealias
, typeof
), Scala (forsome
). Exceptions are Haskell's type family
and type instance
.
Today when you write a list comprehension (
from
expression) the relations are defined by set expressions, but with this proposal you could also define a relation using a boolean function.Suppose we have functions
empsInDept
andempWorksIn
:Today you can write
and it calls
deptEmps
for eachd
value to generate a list ofe
values. But with this proposal, you would be able to go the other way:To a mathematician, both are valid ways to define a set. But to a computer scientist the
bool
function is trickier to work with, because you have to work backwards and 'solve for e'.In some cases it's not possible to work backwards. For example, given a function
isEven
,we don't allow iterating over all even numbers:
With this change, however, we will allow the use of such functions if some other part of the
from
expression provides a finite list of values:Defining relations by means of predicates, and executing queries by 'solving' to find all possible values of variables for which the predicates evaluate to true, is what Datalog does. This change will bring Datalog-style computations into Morel. See #106.