Skip to content

Commit

Permalink
feat: update Home.js (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
magnus-madsen authored Jan 1, 2024
1 parent f95c4ac commit 922c1ed
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 14 deletions.
12 changes: 0 additions & 12 deletions build-scripts/sampleFiles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,5 @@ export const sampleFiles = [
{
name: "Working with Files and Directories",
file: "working-with-files-and-directories.flix",
},
{
name: "Using Laziness for Infinite Streams",
file: "using-laziness-for-infinite-streams.flix",
},
{
name: "Using Laziness for Logging",
file: "using-laziness-for-logging.flix",
},
{
name: "Using Laziness to Compute Fibonacci",
file: "using-laziness-to-compute-fibonacci.flix",
}
];
86 changes: 84 additions & 2 deletions src/page/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class Home extends Component {
</p>

<p className="text-justify">
Flix also supports several <span className="font-weight-bold text-info">unique features</span>,
Flix also supports several <span
className="font-weight-bold text-info">unique features</span>,
including: <span
className="font-weight-bold text-success">a polymorphic effect system</span>, <span
className="font-weight-bold text-success">region-based local mutation</span>, <span
Expand Down Expand Up @@ -340,7 +341,88 @@ def map(f: a -> b \\ ef, l: LazyList[a]): LazyList[b] \\ ef =
<Col md="6">
<Card className="border-0">
<CardBody>
<CardTitle><h4>Traits (Type Classes)</h4></CardTitle>
<CardTitle><h4>Parallelism</h4></CardTitle>
<CardText>
<p>
Flix makes it simple and easy to evaluate <i>pure</i> code in parallel.
</p>
<p>
For example, the code on the right shows a parallel implementation of
the <code>List.map</code> function using the <code>par</code> construct.
</p>
<p>
Internally, the <code>par</code> construct uses
light-weight <code>VirtualThread</code>s.
</p>
</CardText>
</CardBody>
</Card>
</Col>
<Col md="6">
<InlineEditor>
{`///
/// A parallel implementation of the List.map function.
///
def parMap(f: a -> b, l: List[a]): List[b] = match l {
case Nil => Nil
case x :: xs =>
// Evaluate f(x) and parMap(f, xs) in parallel.
par (r <- f(x); rs <- parMap(f, xs))
yield r :: rs
}`}
</InlineEditor>
</Col>
</Row>

<Row className="mb-4">
<Col md="6">
<InlineEditor>
{`def main(): Unit \\ IO =
region rc {
// A channel which can buffer one message.
let (tx, rx) = Channel.buffered(rc, 1);
spawn say("Meow!", tx) @ rc; // thread 1
spawn say("Woof!", tx) @ rc; // thread 2
Channel.recv(rx) |> println
} // Execution is blocked until both threads finish.
/// Sends the string s on the given channel tx.
def say(s: String, tx: Sender[String, r]): Unit \\ r =
Channel.send(s, tx)
`}
</InlineEditor>
</Col>
<Col md="6">
<Card className="border-0">
<CardBody>
<CardTitle><h4>Structured Concurrency</h4></CardTitle>
<CardText>
<p>
Flix supports <a
href="https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/">structured
concurrency</a>.
</p>
<p>
For example, the code on the left shows the creation of a fresh
region named <code>rc</code> in which two threads are spawned.
</p>
<p>
Importantly, control-flow does not leave the region before <i>both</i> threads
have terminated. Hence the two threads cannot outlive the lifetime of their
enclosing region.
</p>
</CardText>
</CardBody>
</Card>
</Col>
</Row>

<Row className="mb-4">
<Col md="6">
<Card className="border-0">
<CardBody>
<CardTitle><h4>Traits</h4></CardTitle>
<CardText>
<p>
Flix uses traits to abstract over types that support a common set of
Expand Down

0 comments on commit 922c1ed

Please sign in to comment.