@@ -238,6 +238,60 @@ def map(f: a -> b \\ ef, l: List[a]): List[b] \\ ef =
238238 </ Col >
239239 </ Row >
240240
241+ < Row className = "mb-4" >
242+ < Col md = "6" >
243+ < Card className = "border-0" >
244+ < CardBody >
245+ < CardTitle > < h4 > Algebraic Effects</ h4 > </ CardTitle >
246+ < CardText >
247+ < p >
248+ Flix supports algebraic effects, i.e. user-defined effects and handlers.
249+ In particular, Flix supports multi-shot resumptions.
250+ </ p >
251+
252+ < p >
253+ Effect-oriented programming, with algebraic effects, allow programmers to
254+ write pure functions modulo effects. Effect handlers enable program reasoning,
255+ modularity, and testability.
256+ </ p >
257+
258+ < p >
259+ For example, the program expresses a < code > greeting</ code > function that is pure
260+ modulo the current time of the day. In < code > main</ code > we call the function
261+ and handle the < code > HourOfDay</ code > effect by getting the real-world time
262+ from Java's < code > LocalDateTime</ code > .
263+ </ p >
264+ </ CardText >
265+ </ CardBody >
266+ </ Card >
267+ </ Col >
268+ < Col md = "6" >
269+ < InlineEditor >
270+ { `import java.time.LocalDateTime
271+
272+ eff HourOfDay {
273+ def getCurrentHour(): Int32
274+ }
275+
276+ def greeting(): String \\ {HourOfDay} =
277+ let h = HourOfDay.getCurrentHour();
278+ if (h <= 12) "Good morning"
279+ else if (h <= 18) "Good afternoon"
280+ else "Good evening"
281+
282+ def main(): Unit \\ IO =
283+ run {
284+ println(greeting())
285+ } with HourOfDay {
286+ def getCurrentHour(_, resume) =
287+ let dt = LocalDateTime.now();
288+ resume(dt.getHour())
289+ }
290+ ` }
291+ </ InlineEditor >
292+ </ Col >
293+ </ Row >
294+
241295 < Row className = "mb-4" >
242296 < Col md = "6" >
243297 < Card className = "border-0" >
@@ -346,60 +400,6 @@ def map(f: a -> b \\ ef, l: LazyList[a]): LazyList[b] \\ ef =
346400 </ Col >
347401 </ Row >
348402
349- < Row className = "mb-4" >
350- < Col md = "6" >
351- < Card className = "border-0" >
352- < CardBody >
353- < CardTitle > < h4 > Algebraic Effects</ h4 > </ CardTitle >
354- < CardText >
355- < p >
356- Flix supports algebraic effects, i.e. user-defined effects and handlers.
357- In particular, Flix supports multi-shot resumptions.
358- </ p >
359-
360- < p >
361- Effect-oriented programming, with algebraic effects, allow programmers to
362- write pure functions modulo effects. Effect handlers enable program reasoning,
363- modularity, and testability.
364- </ p >
365-
366- < p >
367- For example, the program expresses a < code > greeting</ code > function that is pure
368- modulo the current time of the day. In < code > main</ code > we call the function
369- and handle the < code > HourOfDay</ code > effect by getting the real-world time
370- from Java's < code > LocalDateTime</ code > .
371- </ p >
372- </ CardText >
373- </ CardBody >
374- </ Card >
375- </ Col >
376- < Col md = "6" >
377- < InlineEditor >
378- { `import java.time.LocalDateTime
379-
380- eff HourOfDay {
381- def getCurrentHour(): Int32
382- }
383-
384- def greeting(): String \\ {HourOfDay} =
385- let h = HourOfDay.getCurrentHour();
386- if (h <= 12) "Good morning"
387- else if (h <= 18) "Good afternoon"
388- else "Good evening"
389-
390- def main(): Unit \\ IO =
391- run {
392- println(greeting())
393- } with HourOfDay {
394- def getCurrentHour(_, resume) =
395- let dt = LocalDateTime.now();
396- resume(dt.getHour())
397- }
398- ` }
399- </ InlineEditor >
400- </ Col >
401- </ Row >
402-
403403 < Row className = "mb-4" >
404404 < Col md = "6" >
405405 < Card className = "border-0" >
0 commit comments