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

Views (parameterized functions that return a relation) and inlining #54

Closed
julianhyde opened this issue Jun 27, 2021 · 1 comment
Closed

Comments

@julianhyde
Copy link
Collaborator

In Morel, a query is an expression, and a function is a parameterized expression. What a database would call a 'view' is, in Morel, just a function that returns a relation.

You can substitute expressions, predicates (lambda expressions that return bool), and even other functions/views into views.

For example, here we define an empsIn view whose parameters are emps (a table) and predicate (a condition to apply to each row):

let
  fun empsIn emps predicate =
    from e in emps
    where predicate e
in
  from e in (empsIn emps (fn e => e.deptno = 30))
  yield e.name
end;
val it = ["Shaggy","Scooby"] : string list
@julianhyde
Copy link
Collaborator Author

Fixed in 5f17ce1.

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

No branches or pull requests

1 participant