Content deleted Content added
m Add missing DOI |
General fixes, removed orphan tag |
||
Line 1:
{{about|the Flix programming language|other uses|Flix (disambiguation)}}
{{Infobox programming language
| name = Flix
Line 9:
| license = [[Apache License 2.0]].<ref name="license-github">{{cite web |url=https://github.com/flix/flix/blob/master/LICENSE.md|title=Apache License 2.0|via=[[GitHub]]}}</ref>
| website = {{URL|https://flix.dev/}}
| influenced_by = [[
| file_ext = .flix
}}
'''Flix''' is a [[functional programming|functional]], [[imperative programming|imperative]], and [[logic programming|logic]] [[programming language]] developed at [[Aarhus University]], with funding from the [[
The Flix type and effect system supports [[
Flix supports [[Datalog]] programs as [[First-
== Overview ==
Flix is a [[programming language]] in the [[Standard ML|ML]]-family of languages. Its type and effect system is based on [[
While many programming languages support a mixture of functional and imperative programming, the Flix type and effect system tracks the purity of every expression making it possible to write parts of a Flix program in a [[
Flix programs compiles to [[JVM bytecode]] and are executable on the [[Java Virtual Machine]] (JVM).<ref>{{cite book |last1=Yee |first1=Ming-Ho |title=Implementing a Functional Language for Flix |date=2016-09-15 |publisher=University of Waterloo}}</ref>
The Flix compiler performs [[whole program compilation]], eliminates polymorphism via [[monomorphization]],<ref>{{cite web |title=Monomorphise |url=http://mlton.org/Monomorphise |website=mlton.org}}</ref>
Monomorphization avoids [[
Flix supports [[tail call elimination]] which ensures that function calls in tail position never consume stack space and hence cannot cause the call stack to overflow.<ref>{{cite journal |last1=Madsen |first1=Magnus |last2=Zarifi |first2=Ramin |last3=Lhoták |first3=Ondřej |title=Tail call elimination and data representation for functional languages on the Java virtual machine |journal=Proceedings of the 27th International Conference on Compiler Construction - CC 2018 |date=2018 |pages=139–150 |doi=10.1145/3178372.3179499|isbn=9781450356442 |s2cid=3432962 }}</ref>
The Flix compiler disallows most forms of unused or redundant code, including: unused local variables, unused functions, unused formal parameters, unused type parameters, and unused type declarations, such unused constructs are reported as compiler errors.<ref>{{cite web |title=Redundancies as Compile-Time Errors |url=https://flix.dev/blog/redundancies-as-compile-time-errors/ |website=flix.dev}}</ref>
A [[Visual Studio Code]] extension for Flix is available.<ref>{{cite web |title=flix - Visual Studio Marketplace |url=https://marketplace.visualstudio.com/items?itemName=flix.flix |website=marketplace.visualstudio.com |language=en-us}}</ref>
Flix is [[Open-
== Examples ==
Line 40:
=== Hello World ===
The following program prints "[["Hello,
<syntaxhighlight lang="Scala">
Line 91:
=== Parametric Polymorphism ===
The following program fragment illustrates a [[
<syntaxhighlight lang="Scala">
Line 100:
</syntaxhighlight>
The <code>map</code> function recursively traverses the list <code>l</code> and applies <code>f</code> to each element constructing a new list.
Flix supports type parameter elision hence it is not required that the type parameters <code>a</code> and <code>b</code> are explicitly introduced.
Line 106:
=== Extensible Records ===
The following program fragment shows how to construct a [[
<syntaxhighlight lang="Scala">
Line 130:
=== Polymorphic Effects ===
The Flix type and effect system separates pure and impure expressions.<ref name="oopsla2020a"/><ref>{{cite web |title=Programming Flix - Effects |url=https://doc.flix.dev/effects/ |website=flix.dev}}</ref><ref>{{cite web|title=Rust Internals - Flix Polymorphic Effects|url=https://internals.rust-lang.org/t/flix-polymorphic-effects/13395}}</ref>
For example, the following expression is of type <code>Int</code> and is <code>Pure</code>:
Line 184:
A higher-order function that takes multiple function arguments may combine their effects.
For example, the standard library definition of forward [[
<syntaxhighlight lang="Scala">
Line 226:
=== First-class Datalog Constraints ===
Flix supports [[Datalog]] programs as first-class values.<ref name="oopsla2020b"/>
The following edge facts define a graph:
Line 249:
</syntaxhighlight>
In Flix, Datalog programs are values. The above program can be [[Domain-
<syntaxhighlight lang="Scala">
Line 316:
==== Stratified Negation ====
The Flix compiler ensures that every Datalog program value constructed at run-time is [[
For example, the following Flix program contains an expression that cannot be stratified:
Line 327:
</syntaxhighlight>
because the last expression constructs a Datalog program value whose [[
The Flix compiler computes the precedence graph for every Datalog program valued expression and determines its stratification at compile-time. If an expression is not stratified, the program is rejected by the compiler.
The stratification is sound, but conservative. For example, the following program is [[
<syntaxhighlight lang="Scala">
Line 345:
== Design Philosophy ==
Flix is designed around a collection of stated principles:<ref>{{cite web |title=The Flix Programming Language - Principles |url=https://flix.dev/principles/ |website=flix.dev |accessdate=28 August 2020}}</ref>
* [[Expression-
* [[Closed-world assumption]]. The Flix compiler assumes that the source code of the entire program is available at compile-time.
* Pure and impure code is separated. The type and effect system precisely captures whether an expression may produce an effect<ref>{{cite web |title=Taming Impurity with Polymorphic Effects |url=https://flix.dev/blog/taming-impurity-with-polymorphic-effects/ |website=flix.dev}}</ref>
Line 354:
The principles also list several programming language features that have been deliberately omitted. In particular, Flix lacks support for:
* [[
* [[
* [[
== References ==
Line 362:
{{reflist}}
== External
* [https://flix.dev/ The Official Website]
Line 371:
[[Category:Procedural programming languages]]
[[Category:Functional languages]]
[[Category:Logic programming languages]]
[[Category:High-level programming languages]]
|