Network Requests
There are a few ways to get info from an API
await
?
What is const response = await fetch("mysite.com/api/dogs")
{-# Language TypeSynonymInstances, FlexibleInstances #-} | |
module Algj where | |
import Debug.Trace | |
import Data.Maybe | |
import qualified Data.Map as M | |
import qualified Data.Set as S | |
import Control.Monad.Trans.State |
{-# Language TypeSynonymInstances, FlexibleInstances #-} | |
module Algw where | |
import Data.Maybe | |
import qualified Data.Map as M | |
import qualified Data.Set as S | |
import Control.Monad.Trans.State |
There are a few ways to get info from an API
await
?const response = await fetch("mysite.com/api/dogs")
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.
This is the third part of a series about Algebraic Effects and Handlers.
In the preceding parts, we introduced the notions of continuations and control transfer. We saw how to capture the current
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
function isGenerator(x) { | |
return x != null && typeof x.next === "function" | |
} | |
function isFrame(x) { | |
return x != null && x._type_ === 'call_frame' | |
} | |
function call(genFunc, ...args) { |
This is the first post of a series about Algebraic Effects and Handlers.
There are 2 ways to approach this topic:
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.
// 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) | |
} |
function*example() { | |
const x = 10 | |
const y = yield callcc(function*(k) { | |
// ... | |
yield k(20) | |
throw "Unreachable code" | |
}) | |
console.log(x + y) | |
} |