Instantly share code, notes, and snippets.

# Yassine Elouafi yelouafi

• Morocco
Last active April 24, 2024 04:30

In this tutorial we're going to build a set of parser combinators.

## What is a parser combinator?

We'll answer the above question in 2 steps.

1. What is a parser?
2. and, what is a parser combinator?

So first question: What is parser?

Last active April 21, 2024 17:12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 var \$jscomp = \$jscomp || {}; \$jscomp.scope = {}; \$jscomp.arrayIteratorImpl = function (h) { var n = 0; return function () { return n < h.length ? { done: false, value: h[n++] } : { done: true }; }; }; \$jscomp.arrayIterator = function (h) { return { next: \$jscomp.arrayIteratorImpl(h) };
Last active March 1, 2024 15:31
Implementing Algebraic Effects and Handlers

# Algebraic Effects in JavaScript part 4 - Implementing Algebraic Effects and Handlers

This is the final part of a series about Algebraic Effects and Handlers.

So we've come to the core topic. The reality is that we've already covered most of it in the previous parts. Especially, in the third part, where we saw delimited continuations at work.

Last active February 24, 2024 16:03
Operational Introduction to Algebraic Effects and Continuations

# Algebraic Effects in JavaScript part 1 - continuations and control transfer

This is the first post of a series about Algebraic Effects and Handlers.

There are 2 ways to approach this topic:

• Denotational: explain Algebraic Effects in terms of their meaning in mathematics/Category theory
• Operational: explain the mechanic of Algebraic Effects by showing how they operate under a chosen runtime environment

Both approaches are valuables and give different insights on the topic. However, not everyone (including me), has the prerequisites to grasp the concepts of Category theory and Abstract Algebra. On the other hand, the operational approach is accessible to a much wider audience of programmers even if it doesn't provide the full picture.

Last active July 13, 2023 21:41
delimited continuations using javascript generators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // We model the call stack using a linked list of Generators // Each Generator has a _return field pointing back to its parent function stepGen(gen, arg) { const {done, value} = gen.next(arg) if(done) { if(gen._return) { stepGen(gen._return, value) }
Last active April 19, 2023 08:20
Capturing continuations with Generators

# Algebraic Effects in JavaScript part 2 - Capturing continuations with Generators

This is the second part of a series about Algebraic Effects and Handlers.

Note: initially I planned a 3-part series, but since the current post on undelimited continuations ended up taking

Last active April 19, 2023 06:07
Delimited Continuations
Created September 21, 2018 17:05
multi shot continuations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 function isGenerator(x) { return x != null && typeof x.next === "function" } function isFrame(x) { return x != null && x._type_ === 'call_frame' } function call(genFunc, ...args) {
Last active June 12, 2022 14:49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* The MIT License (MIT) Copyright (c) 2014 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Last active June 8, 2022 19:04 — forked from blackslate/gist:695cf7e76348c4948db7
Demo of using project() and unproject() to drag an object parallel to the camera plane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 THREE.JS WORLD