212 karma · joined Dec 20, 2018 (7y ago) · 65 submissions
1.
Making Flix Compiler Errors Helpful and Delightful(blog.flix.dev ↗)
4 points · by jorkadeen · 9mo ago · discuss
comment 1y ago · link · parent
To be me, the interesting question is: What happens when you lie to the type (and effect or ownership) system?
comment 1y ago · link · parent
For systems in production, we have the `Logger` effect and associated handlers.
comment 1y ago · link · parent
- https://koka-lang.github.io/
7.
Effect Systems vs. Print Debugging: A Pragmatic Solution(blog.flix.dev ↗)
11 points · by jorkadeen · 1y ago · discuss
comment 1y ago · link · parent
The goal of Flix -- and typically of any high-level programming language -- is to provide powerful abstractions and constructs that make programming simple, concise, and (often) less error-prone. Here Datalog fits perfectly.
Now that said -- looking through the Flix documentation -- I think we need to do a better job at selling the use case for Datalog. Partly by adding arguments such as the above and partly by adding better examples.
comment 1y ago · link · parent
This is unavoidable when (a) the runtime enviroment, here the JVM, does not support tail calls, and (b) the language wants to guarantee that _any_[1] tail call does not grow the stack.
[1] Any call. Not just a call to the same function.
comment 1y ago · link · parent
This is not just aspirational. It is an iron-clad guarantee; it is what is formally called "effect safety" and it has been proven for calculi that model the Flix type and effect system.
To sum up: In Flix:
- If a function is pure then it cannot perform side-effects.
- If a function has the Console effect then it can only perform operations defined on Console.
- If a function has the Console and Http effect then it can only perform operations defined on Console and Http.
and so on.
comment 1y ago · link · parent
In addition to the imperative `foreach` construct, Flix has two constructs for applicative[1] and monadic[2] comprehensions: `forA` and `forM`. Since applicatives and monads are related, it is useful that their syntax is similar, since it makes it easy to switch between the two. While having camelCase keywords may seem strange, in this case there is a feeling that it works out well. Certainly, `form` or `fora` would be much worse.
Applicative and monadic programming is not a big part of Flix, but it is something we want to support and make ergonomic. Also, these features may have scary names, but the concepts are not too difficult. See [1] and [2] for simple examples of how these features can be used for e.g. error handling.
[1] https://doc.flix.dev/applicative-for-yield.html [2] https://doc.flix.dev/monadic-for-yield.html
comment 1y ago · link · parent
def main(): Unit \ IO =
Map.empty() |>
Map.insert("Hello", "World") |>
Map.get("Hello") |>
println
So I am not sure what you mean? In general, if you like pipelines then you want the "subject" (here the map) to be the last argument. That is how it is in Flix.comment 1y ago · link · parent
Note that there is no requirement that all mutation must occur within a single function. The requirement is that once you leave the lexical scope then all mutable memory associated with that scope become unreachable. Mutation can certainly span over multiple functions.
comment 1y ago · link · parent
I think when it comes to programming language design, sometimes I feel that a design has a 90% chance of being good and a 10% chance of being bad. For the logic constraints (right-to-left vs. left-to-right), I think my confidence is only 70% that we got it right.
comment 1y ago · link · parent
Yes, you can write spaghetti code in any language. But a good language design can help (a) reduce errors and (b) nudge the developer towards writing better code.
comment 1y ago · link · parent
Caveat: Flix sometimes has to box values on the boundary between Flix and Java code -- e.g. when calling a Java library methods that requires a java.lang.Object due to erasure in Java.
comment 1y ago · link · parent
Path(x, z) :- Path(x, y), Edge(y, z).
i.e. an implication from right to left. This structure matches: query p select (x, z) from Path(x, y), Edge(y, z).
So the trilemma is:A. Keep the logic rules and `query` construct consistent (i.e. read from right-to-left).
B. Reverse the logic rules and query construct-- thus breaking with decades of tradition established by Datalog and Prolog.
C. Keep the logic rules from right-to-left, but reverse the order of `query` making it from left-to-right.
We decided on (A), but maybe we should revisit at some point.
comment 1y ago · link · parent
comment 1y ago · link · parent
The language has improved a lot in the years since the post. In particular, the effect system has been significantly extended, Java interoperability is much improved, and some syntax have been updated.
comment 1y ago · link · parent
Flix does not yet have macros-- and we are afraid to add them due to their real (or perceived) (ab)use in other programming languages.
We are actively looking for library authors and if you are interested, you are more than welcome to stop by our Gitter channel.
comment 1y ago · link · parent
(I am one of the developers of Flix)